Overview
Surfaced in #3534561: Integrate with core's default content exporter.
Calculating dependencies is not calculating properly the intermediate dependencies. It only includes "both ends".
E.g. if a component instance depends on a media which depends on a file, we are not getting the right dependencies: "media" dependencies are missing.
See attached failing functional test.
This is a bug that landed in #3457504: XB field type: calculate all dependencies, store them, surface in new Component "Audit" operation and went unnoticed.
Proposed resolution
Expand test expectations in kernel tests, but keep the new functional test.
User interface changes
None. (Other than the implicit consequence: more complete config dependencies means there's more modules/themes whose uninstallation and config whose deletion will be prevented. 👍 That's why this is tagged data integrity
.)
Issue fork canvas-3544604
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
penyaskitoComment #4
wim leersFantastic find!
Comment #5
wim leers@penyaskito discovered this in #3534561: Integrate with core's default content exporter.
Comment #6
wim leersComment #7
effulgentsia commentedNot every stable blocker needs to block an RC, but this one does.
Comment #8
wim leersComment #9
wim leersPer https://git.drupalcode.org/project/canvas/-/merge_requests/23/diffs#note....
I think I've got all the necessary remaining pieces ready locally. Too tired to finish this today though. Will finish tomorrow AM.
Comment #10
wim leersFollow-up created: #3547579: Introduce a new cache tags aware prop shape repository, so changes affecting prop shape calculation can force the re-invoke of hook_canvas_storable_shape_prop_alter. Really, it's not a follow-up for this issue, but just a completely separate bug that was surfaced by this issue's new functional test coverage 😅
Comment #11
wim leersAll done and fixed. Sprinkled ℹ️ remarks for @penyaskito to review and do the final sign-off. He found this, he reported it, he wrote the test coverage to first prove this was broken.
So I think he's the perfect person to confirm that what I did is correct 😊
Comment #12
penyaskito+1 to RTBC. See #3534561-36: Integrate with core's default content exporter though.
Comment #13
penyaskitoConfirmed this fixes the dependencies also for the export as expected (see issue/canvas-3534561@616bb298). Now 100% sure to merge this.
Comment #14
wim leersThanks for all the due diligence you did at #3534561-37: Integrate with core's default content exporter, @penyaskito! 👏🙏
This indeed allows us to merge this with confidence 😊
Comment #16
wim leersComment #18
wim leersComment #19
wim leersActually, this needs update path tests. Similar to the update path + test coverage at https://www.drupal.org/node/3539207.
(We got rid of that update path test coverage in the XB → Canvas rename.)
That'll be a good baseline to establish 👍
Comment #20
penyaskitoComment #22
nagwani commentedComment #23
penyaskitoThis is ready for review. Assigning to Wim, but I think this needs @larowlan's input too.
Comment #24
wim leersJavaScriptComponentconfig entities 😇ReferenceField(Type)PropExpressioninstead? Described how I think that can work.add-*files to construct a config entity with a component instance whose dependencies would've been incorrectly calculated prior to!23are fine, but unnecessarily complex. I think we could instead be using the exact same component tree with aReferenceFieldTypePropExpressionin aStaticPropSourcein all of them. Special case forContentTemplate, where I'd want to see a<code>ReferenceFieldPropExpressionin aDynamicPropSourcein addition.That would then mean that
UpdateIntermediateDependenciesUpdateTestcould become 10x simpler: it'd just check for the same component instance UUID in aPattern, aPageRegion, aContentTemplateand aFieldConfig, and verify that additional dependencies appeared after the update. ForContentTemplate, you'd do an additional check.IOW: the same before vs after expectations could be applied to all of the config-entities-under-test. It'd make the update path test coverage much easier to review and maintain. (And would be an even better reference for future update paths!)
https://www.drupal.org/node/3539207 didn't need to do that because it was an optimization, but here it is a fix that impacts data integrity: without such dependencies, in theory it's possible that e.g. the intermediary Media entity gets deleted because the content entity's component tree depended only on the File entity that the Media pointed to.
However: A) I remember us discussing this and @effulgentsia convincing us we don't need that?, B) deleting content entities doesn't actually check the impact on things depending on it, see
\Drupal\Core\Entity\ContentEntityDeleteFormand\Drupal\Core\Entity\EntityDeleteForm::buildForm(), so even if we did update all revisions' inputs' dependencies in the DB, it would have zero effect. The only effect it would have, is to make Canvas' Audit functionality more precise.Conclusion: I'm fine with proceeding without this, especially given this is not yet a stable module.
Comment #25
wim leers#24.4 has not yet been addressed yet. 🙏 That'd make these tests much easier to understand and much more maintainable.
Comment #26
penyaskitoA snippet that I used for generating + inspecting the dump:
https://git.drupalcode.org/-/snippets/248
#24.4: Added dynamic prop to content template → bd5cb038
+ Simplified tests in multiple commits. It's definitely more compact, not sure if more maintainable tho, I see pros and cons.
Comment #27
penyaskitoIMHO this is ready for reviews now.
Comment #28
wim leersAfter spending more hours than either of us really wanted pairing on this (and the blocking https://git.drupalcode.org/project/canvas/-/merge_requests/219 MR), we both think this is finally ready to go!
🌇
Comment #30
wim leers