Problem/Motivation

With the core patch #3057545: ResourceTypeRepository wrongly assumes that all entity reference fields have the setting "target_type" applied and jsonapi_extras 3.15.0 special entity relation fields are not working anymore as in 3.15.0 ConfigurableResourceTypeRepository::getRelatableResourceTypesFromFieldDefinition was added which overwrites ResourceTypeRepository::getRelatableResourceTypesFromFieldDefinition.

Steps to reproduce

Apply patch #3057545: ResourceTypeRepository wrongly assumes that all entity reference fields have the setting "target_type" and use a dynamic entity reference field.

Proposed resolution

This patch should be applied, if #3057545: ResourceTypeRepository wrongly assumes that all entity reference fields have the setting "target_type" get commited to core.

CommentFileSizeAuthor
#2 3165649-1.patch3.6 KBkfritsche

Comments

kfritsche created an issue. See original summary.

kfritsche’s picture

Status: Active » Needs review
StatusFileSize
new3.6 KB

This should fix the issue as it adapts the changes from #3057545: ResourceTypeRepository wrongly assumes that all entity reference fields have the setting "target_type" to the ConfigurableResourceTypeRepository.

kfritsche’s picture

Alternative solution would be removing ConfigurableResourceTypeRepository::getRelatableResourceTypesFromFieldDefinition and use the parent again. Which would also help in the future or for other patches done to core.

I just had the idea to check if it would be possible to call the parent and work with the result to do what the overridden method does. But thats when I noticed it just adds a warning nothing more, where I'm unsure if this is warning is useful at all.

The warning was added with #3069220: Drupal 9 Deprecated Code Report, but there is no mention in the issue description or comments why it was added and its not related to D9 deprecation warnings at all.

In comment 22 of that issue it seems it was added, which references #2996114: Argument 2 passed to Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of Drupal\jsonapi\ResourceType\ResourceType, NULL given.

I think modules should be really sensible when overriding methods and not calling the parent method.

bbrala’s picture

If we can avoid overwriting code we should indeed keep it out of the module, I agree.

dmitry.korhov’s picture

Status: Needs review » Postponed

Let's have this patch reviewed when Drupal Core issue is merged. Something can change

gaëlg’s picture

Status: Postponed » Needs work

The patch does not apply anymore, and the Drupal core issue is merged.

gaëlg’s picture

Status: Needs work » Fixed

This bug cannot happen anymore since #3384599: Cleanup Drupal 8 code paths is done (>=3.24-beta1).

Status: Fixed » Closed (fixed)

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