Problem/Motivation
Since 2.0.0-alpha4, every page fails on Drupal 10 with HTTP 500:
ServiceNotFoundException: You have requested a non-existent service "Drupal\bs_base\Hook\BsBaseHooks".The Project Update Bot commit in alpha4 moved the hooks into src/Hook/BsBaseHooks.php. The #[LegacyHook] functions left in bs_base.theme call \Drupal::service(BsBaseHooks::class), and the service is defined in a new bs_base.services.yml. Drupal loads services.yml only from modules, so on Drupal 10 the service does not exist. Drupal 11.4 is not affected: its ThemeHookCollectorPass registers a theme's hook classes itself and skips the #[LegacyHook] functions.
Steps to reproduce
- Drupal 10 site with bs_base 2.0.0-alpha4 (or a child theme of it) as the default theme.
- Open any page: HTTP 500 with the error above.
Proposed resolution
The legacy functions use one shared new BsBaseHooks() from a small helper, _bs_base_hooks(), instead of the container; the class has no constructor and keeps no state. Remove bs_base.services.yml, which a theme cannot use. Drupal 11.4 keeps using the class it discovers.
Remaining tasks
- Review, then a new alpha release.
Issue fork bs_base-3634703
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
pivica commentedMR ready.