Problem/Motivation
Following the merge and release of the work in #3293210: Fix PHPCS, deprecations, and test failures to enable DrupalCI testing, any sites running Patternkit on Drupal less than 9.4 will encounter the following fatal error as the library discovery data is being populated:
PHP Fatal error: Uncaught Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::hasImplementations() in /var/www/web/modules/contrib/patternkit/src/Asset/Library.php:747
Stack trace:
#0 /var/www/web/modules/contrib/patternkit/src/Asset/Library.php(303): Drupal\patternkit\Asset\Library->parseLibraryInfo('module', 'automated_cron', 'core/modules/au...')
#1 /var/www/web/modules/contrib/patternkit/src/Asset/Library.php(403): Drupal\patternkit\Asset\Library->buildByExtension('module', 'automated_cron')
#2 /var/www/web/modules/contrib/patternkit/src/Asset/Library.php(589): Drupal\patternkit\Asset\Library->getLibraries()
#3 /var/www/web/modules/contrib/patternkit/src/Asset/Library.php(463): Drupal\patternkit\Asset\Library->getLibraryMetadata()
#4 /var/www/web/modules/contrib/patternkit/src/Loader/PatternLibraryLoader.php(33): Drupal\patternkit\Asset\Library->getLibraryDefinitions()
#5 /var/www/web/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\patternkit\Loader\PatternLibraryLoader->__constru in /var/www/web/modules/contrib/patternkit/src/Asset/Library.php on line 747
This was caused by attempts to resolve the deprecation to the Module Handler service described here. A quick exchange of the implementsHook() call to use hasImplementations() instead resolved the deprecation warning, but since the method doesn't exist prior to Drupal core 9.4, earlier installations will fail.
Steps to reproduce
- Install the Patternkit module into a Drupal instance running 9.3 or less
- Attempt to load a page building the library
- Observe the reported error and white screen failure
Proposed resolution
In the near term, we can resolve this quickly and restore support to the module by rolling back the change despite re-added deprecation notice. As a follow-up item, building and altering the library information using hooks should be adjusted to follow the guidance in the change record allowing the module handler to iterate over all modules instead of incorporating it into the iteration in our module.
Remaining tasks
- Roll back the deprecation update to restore functionality of the module on Drupal core < 9.4
- Complete follow-up work to refactor the library information assembly and use an invokeAll implementation on the module handler service
User interface changes
None
API changes
None
Data model changes
None
Issue fork patternkit-3295521
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 #4
sluceroMerged!