- ๐ฎ๐ณIndia virag.jain
Update 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 theresourceFields
array. 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 inresourceFields
as 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!