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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

olexyy.mails@gmail.com’s picture

Issue summary: View changes
olexyy.mails@gmail.com’s picture

Issue summary: View changes
edutrul’s picture

I 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

                "patches": {
                    "drupal/core": {
                        "Issue #2996114: Argument 2 passed to {closure}() must be an instance of ResourceType, NULL given": "https://www.drupal.org/files/issues/2019-12-03/2996114-99.patch"
                    }
                }

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.

edutrul’s picture

Status: Active » Reviewed & tested by the community
hanoii’s picture

There 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.

olexyy.mails@gmail.com’s picture

This is because of commits that improve performance of JSONAPI suppose this is very big issue for JSONAPI EXTRAS i publish patches that revert
those.

olexyy.mails@gmail.com’s picture

olexyy.mails@gmail.com’s picture

I repeat, CURRENTLY JSONAPI extras not compatible with latest core JSONAPI

e0ipso’s picture

Thanks for the investigation. One recommendation, if the patch is against JSON:API in core, you should open a core issue for that.

bbrala’s picture

Status: Active » Needs review
Related issues: +#3069220: Drupal 9 Deprecated Code Report

This 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?

bbrala’s picture

Status: Needs review » Fixed

Cleaning up, if issue persists, please reopen this issue.

Fixed in #3069220: Drupal 9 Deprecated Code Report

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.