fix: #3620603 Skip the ComponentTreeLoader swap when Canvas ships it final

Fixes the fatal in #3620603: on a Canvas that is not patched, loading CanvasOverrideComponentTreeLoader is a PHP fatal ("cannot extend final class"), which takes the whole site down instead of disabling one feature.

This is the fail-safely route from the issue only. It does not decide the other two — an upstream interface in Canvas (#3567225), or dropping the service swap altogether — both of which are still open questions for the maintainer.

What it does

  • CanvasOverrideServiceProvider::swapComponentTreeLoader() now skips the swap when Canvas ships ComponentTreeLoader as final. The swap is the only place that references our subclass, and it decides without loading it: ::class is a compile-time constant that does not autoload, and the new isComponentTreeLoaderExtendable() reflects on Canvas's own class. So on an unpatched Canvas our subclass is never loaded and nothing fatals.
  • canvas_override_requirements() reports the per-entity component tree override as Active or Inactive, and when inactive explains why and links the patch issue. A silently disabled feature is worse than a visible one.

Verified

On a Drupal CMS 11.4.5 site with drupal/canvas 1.10.1 and this module installed:

Canvas Before After
unpatched (final class) fatal, site does not boot HTTP 200, swap skipped, requirements warning
patched (class, via vardot/varbase-patches #3567225) works HTTP 200, swap applied, requirements Active

Both files pass php -l.

Note on scope

The drupal/canvas: ~1 constraint is left alone deliberately: with this guard the module no longer breaks on a Canvas it cannot extend, so narrowing the constraint would refuse installs that now work fine with one feature off.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading