diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 993689e..cdc7504 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd tools: composer:v2 coverage: none - ini-values: error_reporting=E_ALL + ini-values: error_reporting=E_ALL, zend.assertions=1 - name: Set Laravel Version run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update diff --git a/CHANGELOG.md b/CHANGELOG.md index cebfa2d..38dfa04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/). +## Unreleased + +## [3.2.0] - 2023-11-08 + +### Added + +- Exceptions converted to JSON:API errors when debug mode is on now include all previous exceptions. + +### Changed + +- Registering routes no longer results in the server instance being thread-cached. This more accurately reflects + production environments, where routes would be cached so there would be no thread-cached JSON:API server when handling + a HTTP request. This means tests (and development environments where routes are not cached) more accurately behave in + the same way as production environments. +- Exceptions thrown during the encoding process are no longer caught and re-thrown as previous exceptions. This is due + to the number of questions we receive from developers who do not check previous exceptions, despite exception messages + stating that there is a previous exception to look at. + ## [3.1.0] - 2023-07-20 ### Added diff --git a/composer.json b/composer.json index 9ea9f21..4be1273 100644 --- a/composer.json +++ b/composer.json @@ -25,10 +25,10 @@ "require": { "php": "^8.1", "ext-json": "*", - "laravel-json-api/core": "^3.2", - "laravel-json-api/eloquent": "^3.0", - "laravel-json-api/encoder-neomerx": "^3.0", - "laravel-json-api/exceptions": "^2.0", + "laravel-json-api/core": "^3.3", + "laravel-json-api/eloquent": "^3.1", + "laravel-json-api/encoder-neomerx": "^3.1", + "laravel-json-api/exceptions": "^2.1", "laravel-json-api/spec": "^2.0", "laravel-json-api/validation": "^3.0", "laravel/framework": "^10.0" diff --git a/src/Routing/Registrar.php b/src/Routing/Registrar.php index a33c78d..69d4afa 100644 --- a/src/Routing/Registrar.php +++ b/src/Routing/Registrar.php @@ -21,6 +21,7 @@ use Illuminate\Contracts\Routing\Registrar as RegistrarContract; use LaravelJsonApi\Contracts\Server\Repository; +use LaravelJsonApi\Core\Server\ServerRepository; class Registrar { @@ -55,9 +56,15 @@ public function __construct(RegistrarContract $router, Repository $servers) */ public function server(string $name): PendingServerRegistration { + // TODO add the `once` method to the server repository interface + $server = match(true) { + $this->servers instanceof ServerRepository => $this->servers->once($name), + default => $this->servers->server($name), + }; + return new PendingServerRegistration( $this->router, - $this->servers->server($name) + $server, ); } }