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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3165649-1.patch | 3.6 KB | kfritsche |
Comments
Comment #2
kfritscheThis 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.
Comment #3
kfritscheAlternative 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.
Comment #4
bbralaIf we can avoid overwriting code we should indeed keep it out of the module, I agree.
Comment #5
dmitry.korhovLet's have this patch reviewed when Drupal Core issue is merged. Something can change
Comment #6
gaëlgThe patch does not apply anymore, and the Drupal core issue is merged.
Comment #7
gaëlgThis bug cannot happen anymore since #3384599: Cleanup Drupal 8 code paths is done (>=3.24-beta1).