Problem/Motivation

In #3054850 we removed the sorting by weight, which, although correct, still left the order of the configured negotiators not work correctly.

When this module is calling

$this->languageNegotiator->getNegotiationMethods(LanguageInterface::TYPE_INTERFACE);

The plugins are returned in an unexpected order. The reason is that LanguageNegotiator::getNegotiationMethods() first gets all the plugin definitions (unsorted) and then runs an array_intersect_key with the the ones configured and ordered in the UI. So the order in the UI is no longer kept (the plugin definition order wins). It may work elsewhere for core, but in the case of this module, which loops through these and exits if it encounters the selection page plugin first, other negotiation methods which are configured in the UI to come BEFORE it no longer have a chance.

Steps to reproduce

Add a language negotiation method that gets loaded AFTER the language selection page when calling getDefinitions() on the negotiator plugin manager.

CommentFileSizeAuthor
#2 3212711-2.patch5.88 KBupchuk
#2 3212711-2-test-only.patch4.75 KBupchuk
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:

  • 3212711 Comparechanges, plain diff MR !1
  • 8.x-2.x Comparecompare

Comments

Upchuk created an issue. See original summary.

upchuk’s picture

StatusFileSize
new4.75 KB
new5.88 KB

Here is a patch that fixes it. Also attaching a test-only patch to prove the problem.

upchuk’s picture

pol’s picture

Hi Danny,

Do you think it would be possible to submit a PR on Gitlab ?

Thank you very much!

upchuk’s picture

Status: Needs work » Needs review

Pol,

Done, I think.

upchuk’s picture

Not seeing anywhere the tests running? Did i do this right?

upchuk’s picture

@Pol, thanks, pushed.

  • Pol committed 2c7c8a7 on 8.x-2.x authored by Upchuk
    #3212711: Fix order of negotiation methods in subscriber.
    
pol’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.