Closed (duplicate)
Project:
JSON:API Extras
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Feb 2019 at 07:30 UTC
Updated:
16 Oct 2026 at 11:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoUgh! That's pretty annoying. Is there any chance you can provide a patch for this?
Thanks for reporting.
Comment #3
wim leersI also reported this problem a long time ago.
The root cause:
\Drupal\jsonapi_extras\Entity\JsonapiResourceConfig::onDependencyRemoval()is missing. Here's a start.Comment #4
e0ipsoThis makes sense. Thanks @mortona2k and @Wim Leers. I won't have availability to work on this, but I'll leave this here to see if anyone else has the time to work on a patch for this.
Comment #5
wim leersComment #6
nginex commentedTagging for Drupal Global Contribution Weekend
Comment #7
dsdeiz commentedWould this happen to still be applicable? I've manually tested it by adding a field on "Article" content type, overwritten the resource type "node--article", and then removed the newly added field. I checked the form "node--article resource config" and the removed field is not listed anymore.
Comment #8
dmitry.korhovFound that adding fields as dependencies for JsonapiResourceConfig leads to placing configuration to "delete" block.
Investigations for make it as "update" are required. Probably separation jsonapi_extras resource config to per field configs are required to make this config update work correctly.
Let's continue with this patch.
Comment #9
bbralaAny chance the work here can continue? Seems like a worthy issue.
Comment #10
rohit.rawat619 commentedComment #11
rohit.rawat619 commentedComment #12
bbralaComment #13
bbralaComment #14
jrockowitz commentedI was experimenting with this patch and a bunch of update hooks failed with the below error
Sorry, I can't provide more details.
Comment #15
virag.jain commentedUpdate on the issue:
An initial attempt was made to fix this by implementing
\Drupal\jsonapi_extras\Entity\JsonapiResourceConfig::onDependencyRemoval(), as pointed out by @Wim Leers, with the goal of cleaning up deleted fields from theresourceFieldsarray. However, it turned out that the methodonDependencyRemoval()wasn’t being triggered at all when a field was removed.Upon further investigation, it appears the root cause is that
\Drupal\jsonapi_extras\Entity\JsonapiResourceConfig::calculateDependencies()only adds the only adds the bundle (e.g.node.type.*) as a dependency; it doesn’t include individual field configs likefield.storage.node.field_foo. Without those dependencies, the entity system doesn’t invokeonDependencyRemoval()when fields are deleted.Proposed solution:
The plan is to update
calculateDependencies()to explicitly add each field listed inresourceFieldsas a dependency (e.g.,field.storage.node.field_foo). With that in place,onDependencyRemoval()will be properly triggered when a field is deleted.Inside
onDependencyRemoval(), any removed fields will be automatically cleaned out of the override config. This prevents stale field entries from lingering in the YAML and eliminates the need for manual cleanup.Just wanted to check in and see if this approach makes sense before finalising the patch. Let me know your thoughts!
Comment #16
virag.jain commentedComment #17
virag.jain commentedComment #18
joachim commentedComment #19
bbralaFixing this in #3540290: Adding fields to entity type does not update jsonapi_resource_config for the entity type, will convert credits to that issue.