Problem/Motivation
The entity_dependency_visualizer_depcalc submodule renders a graph, but the graph is wrong in two ways. Both come from DependencyCollector, which has carried @todo markers since it was added in #3275266 and was never finished.
1. Arrow labels are literal placeholder strings.
DependencyCollector::onCalculateDependencies() populates the dependency info with hard-coded text instead of real values:
'bundle' => '@todo bundle', // @todo: Call $this->getEntityBundle($entity), ... 'field' => '@todo add field',
so every arrow in the graph is labelled:
bundle/name: @todo bundle url: taxonomy_term/2 field: @todo add field
The Native calculator fills both of these in correctly, so switching the calculator plugin silently degrades the graph.
2. References are missing from the graph.
The same file already carries // @todo: Fix bug of missing arrows. and the bug is real: for identical content, DepCalc draws fewer edges than Native.
Steps to reproduce
On Drupal 11 with drupal/depcalc 1.23 installed (depcalc has no Drupal 12 release yet, which is why the submodule declares ^10.2 || ^11):
- Enable
entity_dependency_visualizer,depcalcandentity_dependency_visualizer_depcalc. - Create an Article with an entity reference field to nodes (
field_related) and one to taxonomy terms (field_tags). - Create two terms, T1 and T2, and two articles: Child, with
field_tags= [T2]; and Parent, withfield_tags= [T1, T2] andfield_related= [Child]. - Visit
/node/<parent>/entity_dependencieswith the calculator set to Native, then set it to DepCalc at/admin/config/development/entity_dependency_visualizer/settings, rebuild caches, and visit it again.
Native produces four edges:
Parent -> Child field: field_related Parent -> T1 field: field_tags Parent -> T2 field: field_tags Child -> T2 field: field_tags
DepCalc produces three, with Parent -> T2 missing, and every label reads bundle/name: @todo bundle / field: @todo add field.
Proposed resolution
- Replace the placeholders with the real values. The abstract calculator already provides
getEntityBundle($entity), which is what the inline@todocomment points at. The field name is harder: DepCalc reports deapendencies per entity rather than per field, so the collector needs to work out which field on the parent produced each child. The Native calculator now records this aschild_fields[<child uuid>] = <field name>on the parent, andGraphviz::getArrowLabel()reads that first, so populating the same key here is enough to make the labels correct. - Find out why
Parent -> T2is dropped. A likely cause is that the collector keys$deplistby wrapper uuid and each entity is only visited once, so a term already collected as a child of one entity is not re-registered as a child of another. This needs confirming againstDependentEntityWrapper::getChildDependencies().
Remaining tasks
- Fix the labels.
- Fix the missing edges.
- Add test coverage for the DepCalc calculator. There is currently none: the test suite only exercises the Native plugin, which is why both of these survived. A kernel or functional test asserting that the DepCalc graph has the same edge set as the Native graph for the same content would cover both bugs at once.
User interface changes
Arrow labels in DepCalc mode will show real bundle and field names, and the graph will show the references it is currently missing.
API changes
None expected.
Notes
- Both bugs predate #3597677 and were found while testing that branch; that branch deliberately did not touch them.
drupal/depcalc1.23 requiresdrupal/core ^9.4.15 || ^10 || ^11, so Drupal 12 support for this submodule is blocked on depcalc itself and belongs in a separate issue.
Comments
Comment #2
marcelovani