Prior versions of the JSON:API module incorrectly returned ResourceResponse
objects that implemented CacheableResponseInterface
for all of its responses, even uncacheable ones. This caused avoidable fatal errors under specific conditions.
In order for JSON:API to be more nuanced about cacheable vs. uncacheable responses, a new class has been introduced: CacheableResourceResponse
. This class implements CacheableResponseInterface
. Accordingly, Drupal\jsonapi\ResourceResponse
no longer implements CacheableResponseInterface
.
JSON:API's ResourceResponse
class has this documentation:
@internal
JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
If your site relies on this internal class's implementation of CacheableResponseInterface
, please refactor your code to use the new CacheableResourceResponse
class wherever a cacheable response is appropriate (e.g. for all HEAD
, OPTIONS
, and GET
requests). CacheableResourceResponse
is a drop-in replacement.