Problem/Motivation

Get message: Hook Event Dispatcher (Unsupported) Current version 8.x-2.05 Recommended version 3.2.0

Steps to reproduce

Check the module update tab

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon 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

Adrianm6254 created an issue. See original summary.

aangel’s picture

Thanks for the report. Because version 3 of hook_event_dispatcher is a major upgrade and they note it may not be backward compatible, that forces LBK to create a new branch (version 2) since we can't force current users to upgrade and potentially cause problems. There may be other dependencies that should be upgraded at the same time. We'll take a look.

cpigott’s picture

Is there anything anyone can do to speed up resolution of this? The daily emails are making me sad :(

joelsteidl’s picture

@aangel

Would you be willing to create a 8.x-3.x or 3.x branch? If so, I'd be happy to create a merge request so we can see if the 3.x version of hook_event_dispatcher breaks things too badly.

Thanks!

zterry95 made their first commit to this issue’s fork.

zterry95’s picture

I'm using hook_event_dispatcher:3.2 in my local, and works good.
So I create a MR just change the hook_event_dispatcher from 2 to 3, hope it helps and can be merged.

joelsteidl’s picture

@zterry95 I'm actually seeing quite a few errors. Layout Builder Kit will need some work to use hook_event_dispatcher 3.x.

For example ThemeEvent is now part of a submodule called core_event_dispatcher

cpigott’s picture

I've just tried the merge request out, unfortunately I've run into some errors when clearing the cache (i.e. before I've even tried using the module):

PHP Fatal error:  Uncaught Error: Class 'Drupal\\core_event_dispatcher\\ThemeHookEvents' not found in /var/www/drupal/web/modules/contrib/layout_builder_kit/src/Plugin/Block/LBKIconText/LBKIconTextEventSubscriber.php:37
Stack trace:
#0 /var/www/drupal/web/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php(37): Drupal\\layout_builder_kit\\Plugin\\Block\\LBKIconText\\LBKIconTextEventSubscriber::getSubscribedEvents()
#1 /var/www/drupal/vendor/symfony/dependency-injection/Compiler/Compiler.php(94): Drupal\\Core\\DependencyInjection\\Compiler\\RegisterEventSubscribersPass->process(Object(Drupal\\Core\\DependencyInjection\\ContainerBuilder))
#2 /var/www/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(762): Symfony\\Component\\DependencyInjection\\Compiler\\Compiler->compile(Object(Drupal\\Core\\DependencyInjection\\ContainerBuilder))
#3 /var/www/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(1297): Symfony\\Component\\DependencyInjection\\ContainerBuilder->compile()
#4 /var/www/drupal/web/core/lib/Drupal/Co in /var/www/drupal/web/modules/contrib/layout_builder_kit/src/Plugin/Block/LBKIconText/LBKIconTextEventSubscriber.php on line 37
 [warning] Drush command terminated abnormally.

Looking at the composer log, it seems to have removed core_event_dispatcher ? But it's also included inside hook_event_dispatcher? I'm not quite sure of the relationship between these packages

        "  - Removing drupal/core_event_dispatcher (3.3.1)",
        "  - Upgrading drupal/hook_event_dispatcher (2.5.0 => 3.3.1)",
        "  - Upgrading drupal/layout_builder_kit (1.0.0-beta5 => dev-3282326-hookeventdispatcher2.5.0-is-no 312982e)",
cpigott’s picture

On looking deeper, this appears to be related to https://www.drupal.org/project/hook_event_dispatcher/issues/3285706

However I haven't found a workaround for it - my attempt to just comment out the offending bits of code in all the layout_builder_kit/src/Plugin/Block/LBK*/*EventSubscriber.php files until I could actually properly rebuild cache/update db, then put them back again doesn't seem to have worked - the class is still unavailable

joelsteidl’s picture

@cpigott

It makes me feel better that you found an issue. It was driving me crazy and I ended up giving up for the time being. The code changes in Layout Builder Kit were minimal, so hopefully everything will work as expected once hook_event_dispatcher resolves that issue.

cpigott’s picture

Trouble is that the linked issue doesn't really have any satisfactory workaround, which I'd say pretty strongly blocks this MR - I'd be very surprised if I'm going to be the only one to run into this otherwise....

The possible workarounds I can see is either wrapping all the usages of ThemeHookEvents in a `if (class_exists)`, or just hardcoding the names and not using ThemeHookEvents at all. Neither of which feel particularly nice.

Apparently none of the other modules that I'm currently using that use getSubscribedEvents (need to?) use the class_exists workaround anywhere, though a few do hardcode the names

Any thoughts on which workaround is more feasible?

aangel’s picture

I've opened the 2.x branch, merged this and other MRs and my initial testing is positive using the 3.x branch of HED.

If anyone wants to try it, I've tagged a 2.0.0-dev. In composer, use:
"drupal/layout_builder_kit": "2.x-dev"

I also tried it against D10 but there's a PHP8 requirement that's not worked out with one of the dependencies; it installs with:
composer update --ignore-platform-reqs

cpigott’s picture

Excellent to see some progress.

Briefly tried it out, but still getting the issue with ThemeHookEvents mentioned above

I see you tried using HookEventDispatcherInterface in https://git.drupalcode.org/project/layout_builder_kit/-/commit/ecfb8d730... , but later reverted it. What was the reason for the reverting?

aangel’s picture

@cpigott I reverted that commit because I came across this change record noting that those constants are being deprecated:

Events constant in \Drupal\hook_event_dispatcher\HookEventDispatcherInterface are deprecated
https://www.drupal.org/node/3263301

Regarding not having access to the constants before the module is enabled, there seems to be a leaning toward using class names, per:
https://www.drupal.org/project/drupal/issues/2825358#comment-14432778

aangel’s picture

I'm running low on other things to do and I, too, am stuck on the ThemeHookEvents issue. Tomorrow I'll try posting a question somewhere.

aangel’s picture

2.0.0-alpha2 is ready for folks to try. Had to use a hardcoded string ($events['hook_event_dispatcher.theme']).