Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I cannot tell if this is a documentation issue or a code issue, but in testing #2098119: Replace config context system with baked-in locale support and single-event based overrides I ran into a race condition between two EventSubscribers.
One is a KernelEvent subscriber, the second a ConfigOverrideEvent subscriber.
The second is dependent on the first.
These values "work" for the two subscribers.
// DomainSubscriber
$events[KernelEvents::REQUEST][] = array('onKernelRequestDomain', 300);
// DomainConfigSubscriber
$events['config.module.overrides'][] = array('onDomainModuleOverride', 400);
These values do not:
// DomainSubscriber
$events[KernelEvents::REQUEST][] = array('onKernelRequestDomain', 100);
// DomainConfigSubscriber
$events['config.module.overrides'][] = array('onDomainModuleOverride', 400);
I have working code and SimpleTests for this in https://github.com/agentrickard/domain
Comments
Comment #1
agentrickardComment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedthanks for posting this, will dig around this weekend.
Comment #3
Crell CreditAttribution: Crell commentedMost likely that's because there is another listener between 300 and 100 weight that is interfering. You can get a list of all listeners (or close to) by grepping for $events[KernelEvents::REQUEST]. See if any look suspicious.
Comment #4
dawehner...
Comment #5
agentrickardWell, the DX WTF on this is that the subscribers are keyed, and I would expect that the keys indicate some order of operations, not that all events are thrown into one big bucket.
@Crell
Are you suggesting that events are queued by type (e.g. Kernel fires first) and that something in the Kernel Request stack is causing the issue?
Comment #6
agentrickardOf course, I cannot replicate this today....
Comment #7
Crell CreditAttribution: Crell commentedKey distinction: LISTENERS are callables that are registered with a priority for an event. SUBSCRIBERS are classes that conveniently contain one or more listeners.
The static method in a subscriber class lists the methods of that class which are listeners, and their priority. That priority controls the order in which listeners for that even will be called, regardless of the subscriber class they happen to be defined in.
I was suggesting how you could track down all LISTENERS registered to the kernel.request event (aka, KernelEvents::REQUEST), and see what their priorities are.
Comment #19
Amber Himes MatzHey @agentrickard, I'm triaging this 8-yr-old issue as part of the Bug Smash Initiative. Did the comment in #7 clarify the issue enough for this issue to be closed, or is it still a problem/confusion/DX issue? Would like to close if it's no longer applicable or reproducible. Cheers.
Comment #21
smustgrave CreditAttribution: smustgrave at Mobomo commentedIf still a valid task please reopen updating issue summary addressing #19.
Thanks!