Problem/Motivation
Commerce email is not sending any email. It fails in subscribe to commerce events because the service "plugin.manager.commerce_email_event" is not yet available during getSubscribedEvents() execution.
Steps to reproduce
I think is some arbitrary, because it depends on service discovery order.
Im using Drupal 9.2.4 with this issue fork of commerce email: Automated Drupal 9 compatibility fixes (3147252)
Proposed resolution
Refactor getSubscribedEvents() method in src/EventSubscriber/EmailSubscriber.php to prevent it from being dependent on execution at runtime (as it is recomended in EventSubscriberInterface method documentation)
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
ecdani commentedComment #3
ecdani commentedI've changed the subscription mechanism to make it more deterministic.
Now it relies on the "onRequest" kernel event (that it executes before any commerce event) to do the rest of event subscriptions.
Comment #4
rszrama commentedAh! I noticed this, too, but couldn't figure it out ... just realized that flushing caches in the UI made it work where rebuilding the cache via drush didn't. Your solution appears to have done the trick.
Comment #6
rszrama commentedCommitted.
Comment #8
jsacksick commentedThis introduced a break with Drupal 8. The module still claims D8 compatibility, but Symfony\Contracts\EventDispatcher\EventDispatcherInterface was introduced in D9.1 (See https://www.drupal.org/node/3159012).