fix: #3605988 Self-heal stale Canvas component versions on build, install, theme enable and rebuild
Fixes #3605988.
What this does
On a fresh Varbase build, or after generating a sub-theme and switching the default theme, the Drupal Canvas page editor could fail to open a page (HTTP 500 / "requested version is not available") with repeated "Component version … not found, falling back to active version" warnings.
Root cause: Canvas regenerates its SDC component config entities on cache rebuild, module install and theme install (createVersion() records the new active version, deleteVersionIfExists() drops the previous one). Any config/content that still pins the previous hash is left stale. Page render falls back gracefully; the editor surfaces the mismatch. The existing theme-switch heal runs before the new theme's components are regenerated, and a fresh build never runs drush varbase-components:fix-versions — so stale versions survive.
Fix:
ActiveThemeChangeSubscriber::heal()— a public, idempotent, full-scope repair that reuses the existingfixComponentVersionsInConfigs()+fixComponentVersionsInContentEntities()(the exact pair the Drush command runs), after resetting the component cache.- Invoked automatically from
hook_rebuild,hook_modules_installedandhook_themes_installed— which run after Canvas regenerates components. No-op when Canvas is absent. varbase_components.installweights the module after Canvas so the heal always runs once components are current.
Testing
On Drupal 11 + Varbase 11: fresh install → generate + build a sub-theme → switch default. Injected a stale component version into content, then drush cr — the version self-healed to active with no manual command, and the Canvas editor opens the page with no 500 / version error (only benign favicon + one-time drimage warnings).
AI usage disclosure
AI-Generated: Yes — an AI assistant helped root-cause the issue and implement this change; all code was reviewed and tested by the contributor, per the Drupal policy on the use of AI when contributing to Drupal.
Checkpoints
- File an issue about this project
- Addition/Change/Update/Fix to this project
- Testing to ensure no regression
- Automated unit/functional testing coverage
- Developer Documentation support on feature change/addition
- User Guide Documentation support on feature change/addition
- UX/UI designer responsibilities
- Accessibility and Readability
- Code review from 1 Varbase core team member
- Full testing and approval
- Credit contributors
- Review with the product owner
- Update Release Notes
- Release