Problem/Motivation
There is an interface change coming from jsonapi module that is planned in #2992833: Add a version negotiation to revisionable resource types. With the patch from there applied, this module breaks - all resources that are have been exposed by the module will be exposed with no fields attached, due to __construct interface mismatch / misuse.
The case is described in this comment:
This is how jsonapi_extras is creating resource types from the repository. As they are not overwriting the constructor, the base class one is invoked and for the place that you see here $field_mapping, in the jsonapi with this patch the signature is expecting $is_versionable, and the actual list fields falls back to empty list, due to a default argument :(.
// Create subclassed ResourceType object with the same parameters as the
// parent implementation.
$resource_type = new ConfigurableResourceType(
$entity_type->id(),
$bundle,
$entity_type->getClass(),
$entity_type->isInternal() || (bool) $resource_config->get('disabled'),
static::isLocatableResourceType($entity_type, $bundle),
TRUE,
$field_mapping
);
As there are no additional arguments - this is passing empty list for fields_mapping resulting in empty responses (no attributes in the objects...).Either way jsonapi_extras will need a follow-up once this is in... Should I create one and patch the case I am trying to describe?
Proposed resolution
Extend the creation method, so we are passing the is_versionable flag during the ResourceType creation.
Remaining tasks
discussion, patch, etc.
User interface changes
None...
API changes
New argument in ConfigurableResourceType class, inherited from jsonapi module.
Data model changes
Nothing big - just one more flag...
Release notes snippet
TBD.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3020112-3.patch | 649 bytes | ndobromirov |
Comments
Comment #2
ndobromirov commentedComment #3
ndobromirov commentedHere is the patch that made both work for me.
Comment #5
ndobromirov commentedPostponing based on the parent issue status.
Adding API-First tag, due to the parent issue being marked as such.
Needs manual testing as it needs the patched version of jsonapi to show the issue and this patch to resolve it.
Comment #6
ndobromirov commentedThis is fixing some of it. On further testing it seems that relationships are not having fields as well... Researching...
Comment #7
ndobromirov commentedThe issue is coming from this return statement in jsonapi_extras...
For some reason NULL configs are not using default settings for fields list etc so in my case only 10 out of 130 configs are overwritten.
The issue even if same might not be related...
The issue is that the old default behavior is failing, so anything that has not overwritten configs in jsonapi_extras will get an empty fields list, as it's always going in the above scenario.
Comment #8
ndobromirov commentedI've opened a separate issue for the one described in #7: #3020237: [Regression] Broken with latest jsonapi 2.0-rc3
Comment #9
ndobromirov commentedThis is not needed anymore as
JSON:APIandJSON:API Extrashave included revisions support and the two latest stable versions are working correctly.