- Issue created by @classiccut
- 🇨🇦Canada classiccut
This patch adds the entry for request subscriber in the services.yml file.
- 🇧🇪Belgium andreasderijcke Antwerpen / Gent
Ah, good catch. Didn't even notice that.
Weird that it can work sometimes without... What core version are you using? - 🇧🇪Belgium andreasderijcke Antwerpen / Gent
Actually, the services is registered conditionally: https://git.drupalcode.org/project/cookiepro_plus/-/blob/1.0.x/src/Cooki...
I don't recall why we made it dependent on the presence of the 'language_request_subscriber', but it seems unnecessary right now.
The 'language_request_subscriber' service is also registered conditionally, see https://git.drupalcode.org/project/drupal/-/blob/10.2.x/core/modules/lan.... Perhaps the isMultilingual() does not return TRUE in your case?
I'm curious to know if this is the root cause of your observations, and if so, if that it is (still) relevant or not.
- 🇨🇦Canada classiccut
Thanks for clarifying. Yes I guess it makes sense to make it conditional. From what I can tell in my environment (Drupal WxT 5.1.0 with Drupal core 10.1.6, URL language detection with domain configuration), the LanguageServiceProvider's register method gets called after the CookieProPlusServiceProvider's register method, which would explain why the condition isn't met.
- 🇧🇪Belgium andreasderijcke Antwerpen / Gent
I guess the idea was to not have a hard dependency on the language manager service?
I think the reason is, that if LanguageRequestSubscriber runs, it must run before our subscriber, so
- we are sure the language override is properly set,
- we want to update our config ASAP afterwards, before other stuffs starts using our service
What I still don't get, is why it runs after the LanguageRequestSubscriber in your case. Is the weight of that event subscriber changed?
A quick install of the WxT 5.1.0 codebase indicates it should be the same as default core (255), while mine is 250:How does that look on your end?
In the mean time, I'll see if there is a way to make sure ours runs always after LanguageRequestSubscriber.
- 🇨🇦Canada classiccut
Interesting. I see the same priority for cookiepro request subscriber and language request subscriber as yours, but with an extra wxt subscriber at priority 255.
- 🇧🇪Belgium andreasderijcke Antwerpen / Gent
That's indeed interesting. Could be a core bug.
In anyway, to make sure that, from the module point of view, the LanguageRequestSubscriber has run first, the decorator approach might work better. I can't find an example in core of decorators on event subscribers, but it seems to work.
The decoration_on_invalid isn't supported by the core YamlFileLoader, but it works when registering using a service provider.
I do need to extract and cleanup my code changes a bit and then will post a patch for you to test.
- Merge request !8Issue 3437711 Use decorater pattern instead of conditionally registering our... → (Merged) created by andreasderijcke
- 🇧🇪Belgium andreasderijcke Antwerpen / Gent
@ClassicCut Can you test/confirm the change of the MR please?
- Status changed to Needs review
9 months ago 9:17am 5 April 2024 - 🇨🇦Canada classiccut
Thanks for putting this together! I can confirm that it works on my environment. Correct script IDs are loaded for the overridden languges.
- Status changed to Fixed
8 months ago 8:33pm 16 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.