fix(Component sources): #3591628 Generate Components from the live container after canvas_stark install reboots the kernel on Drupal 11.3

Closes #3591628 (closed)

What this MR does

In ComponentSourceHooks::modulesInstalled(), after installing canvas_stark, the Components are now generated via the ComponentSourceManager resolved from the kernel's current container, instead of the one injected into the hook. On Drupal 11.3 the canvas_stark install reboots the kernel and rebuilds the container mid-hook (core: ThemeInstaller now resets the container in install/uninstall — https://www.drupal.org/node/3551652), which orphans the injected manager and its PersistentPropShapeRepository. Generating from the live container ensures the prop shape repository whose cache outlives the install is the one that gets populated, so later configuration changes (e.g. creating a media type) regenerate the affected Components.

How to test

  • On Drupal 11.2, run tests/src/Functional/PropExpressionDependenciesTest.php — passes.
  • On Drupal 11.3, run the same test — passes (it failed before this change, at the entity:media assertion).
  • composer phpstan and composer phpcs are clean.
  • Kernel tests/src/Kernel/PropShapeRepositoryTest.php still passes (no regression).
  • Manual (the issue STR): on a fresh Minimal install with Canvas + canvas_test_sdc on 11.3, create an image media type before opening Canvas, then add the card with a stream-wrapper image component — the image prop now offers the media library widget without a cache rebuild.

Notes for reviewers

  • Only hook_modules_installed needs this: hook_rebuild() is invoked via a freshly resolved handler each time, so its injected manager is not stale.
  • ⚠️ Running the test on Drupal 11.3 also requires justinrainbow/json-schema < 6.9.0. 6.9.0 changed $ref resolution so the image prop shape becomes non-storable (the SDC component is never created → the test fails earlier, at line 122, for an unrelated reason). That is a separate Canvas incompatibility and should be its own issue; Canvas currently allows it via ^6.8.0.#3591629 (closed)
  • AI use disclosure (per Drupal's policy): the root-cause diagnosis (incl. git bisect to 987c26102), the fix, and this description were produced with AI assistance (Claude Opus 4.8) under human review.
Edited by Wim Leers

Merge request reports

Loading