Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem just after switch to 8.8:
ResourceTypeRepository in method all() returns array for ResourceTypes keyed by json_api config resourceType name
WHILE method getRelatableResourceTypesFromFieldDefinition of same ResourceTypeRepository tries to match related resource types
by default convention:
return array_map(function ($target_bundle) use ($entity_type_id, $resource_types) {
$type_name = "$entity_type_id--$target_bundle";
return isset($resource_types[$type_name]) ? $resource_types[$type_name] : NULL;
}, $target_bundles);
Thus returns null that is unhandled while rotes rebuild and throws error:
TypeError: Argument 2 passed to Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of Drupal\jsonapi\ResourceType\ResourceType, null given in /home/oos/stamkort/web/core/modules/jsonapi/src/Routing/Routes.php on line 434 #0 [internal function]: Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}(false, NULL)
I have almost all resourceType overriden in my configs... This is blocker for migrating to 8.8
If I change in method all()
from
$resource_type->getTypeName() => $resource_type,
to
$resource_type->getJsonapiResourceConfig()->id() => $resource_type,
This works, but i do not exactly know if this will not break anything else.
Comment | File | Size | Author |
---|---|---|---|
#8 | d88.patch | 1.5 KB | olexyy.mails@gmail.com |
Comments
Comment #2
olexyy.mails@gmail.com CreditAttribution: olexyy.mails@gmail.com commentedComment #3
olexyy.mails@gmail.com CreditAttribution: olexyy.mails@gmail.com commentedComment #4
edutrul CreditAttribution: edutrul as a volunteer and at Lullabot commentedI am having this issue but in core version 8.5
I couldn't reproduce this issue locally but I did reproduce on server.
But this is already figured out in "contentacms/contenta_jsonapi": "dev-8.x-3.x" (as far as I am aware)
there's a patch for drupal/core
on server I had this issue since the patch wasn't applied even thought I was executing composer install (even If I removed web/core folder). At the end I realized when running $ composer install -vvv it said "Patch not found". So I needed to install patch software package.
$ yum install patch
Then
$ composer install -vvv
and whoala! it applied patch successfully.
Comment #5
edutrul CreditAttribution: edutrul as a volunteer and at Lullabot commentedComment #6
hanoiiThere is nothing to review and test on this issue.
Although the patch mentioned on #4 for core mitigates the issue it's really not a fix, and the issue has diverged a bit into just providing some input on what the issue is, not preventing the error.
I think this is still something valid to sort on this module.
Comment #7
olexyy.mails@gmail.com CreditAttribution: olexyy.mails@gmail.com commentedThis is because of commits that improve performance of JSONAPI suppose this is very big issue for JSONAPI EXTRAS i publish patches that revert
those.
Comment #8
olexyy.mails@gmail.com CreditAttribution: olexyy.mails@gmail.com commentedComment #9
olexyy.mails@gmail.com CreditAttribution: olexyy.mails@gmail.com commentedI repeat, CURRENTLY JSONAPI extras not compatible with latest core JSONAPI
Comment #10
e0ipsoThanks for the investigation. One recommendation, if the patch is against JSON:API in core, you should open a core issue for that.
Comment #11
bbralaThis should be fixed in the work done in #3069220: Drupal 9 Deprecated Code Report and released in 8.x-3.15. Mind checking it out?
Comment #12
bbralaCleaning up, if issue persists, please reopen this issue.
Fixed in #3069220: Drupal 9 Deprecated Code Report