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.
In ChainStoreResolver priority of the service is a key of resolvers array, this causes a problem when two or more resolver services have the same priority. In this case only 1 resolver will be triggered, because all other will overwrite the array with the same key.
/**
* {@inheritdoc}
*/
public function addResolver(StoreResolverInterface $resolver, $priority) {
$this->resolvers[$priority] = $resolver;
}
The same chain is used for price resolvers but there is no $priority as a key of array.
Comments
Comment #2
mglamanCan you test and prove this? Because the priority should be adjusted by the container to prevent conflicts.
EDIT: The logic is here \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass::process
If there is an issue, then you either need to manually resolve, or Core will need to..
Comment #3
agoradesign CreditAttribution: agoradesign commentedThe price resolvers definitely work without setting the prio as array key (with correctly ordered resolvers). So if we can prove, that explicitely setting the key is causing problems, why don't we simply change the chain store resolver to behave like the price resolver?
Comment #4
mglamanYeah, lets' do that. I remember when dealing with priority I was a bit inept at understanding out how worked. We shouldn't pass the priority parameter and just
[]
it, as the container adds.Comment #5
agoradesign CreditAttribution: agoradesign commentedhaha, I know that.. was the same with my price resolvers. I had to play around with different priority values of my custom resolver in order to understand Drupal's/Symfony's behaviour here
Comment #6
a.dmitriiev CreditAttribution: a.dmitriiev as a volunteer and at 1xINTERNET commentedPlease add to the next commit :) Because now it is a bit confusing.
Thanks.
Comment #7
bojanz CreditAttribution: bojanz at Centarro commentedOkay, so we basically want to revert #2796005: Chain resolvers do not support tagged service priority..
I'm fine with that, since we aren't doing our own sorting by priority and deduplicating anyway.
Sure would be nice to have a single ChainResolver. Need to look into that again.
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedDone. Gave the commit credit to steveoliver cause I owe him one from #2832595: Payments tab on orders no longer shows up.