Problem/Motivation
#2107427: Regression: Language names should display in their native names in the language switcher block or some other issue might remove the only usage of sortByWeightAndTitle
This issue tracks that the function it self, the test and data provider should be removed.
Quite a few issues have tried to remove this sortByWeightAndTitle() or had trouble with it.
#2107427: Regression: Language names should display in their native names in the language switcher block
#2226533: Changes to the Language class due to the LanguageInterface (followup)
#2315095: EntityTranslationTest webtest random failure in some patches (not HEAD)
#2239399: Languages should be sorted by label instead of title
#2304651: Core Language sort() should not work, needs to use name instead of default title
It was added a while ago in #2151223: Add a method to SortArray to sort by weight and title
Proposed resolution
Once the usage is gone, remove the things.
Also, maybe think about other sorts that access properties.
And, maybe think about if sort should be on some language interface.
Remaining tasks
User interface changes
No.
API changes
Yeah, removing a method.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | interdiff.2332739.11.18.txt | 3.95 KB | yesct |
| #18 | 2332739.18.patch | 5.75 KB | yesct |
| #17 | interdiff.2332739.10.11.txt | 902 bytes | yesct |
| #17 | 2332739.11.patch | 9.08 KB | yesct |
| #13 | 2332739.10.patch | 8.81 KB | yesct |
Comments
Comment #1
yesct commentedComment #2
yesct commentedwant to see what this would look like.
not sure if the Language::sort() should be typehinted with Language or LanguageInterface.
note #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface got in.
Maybe sort() should be on the LanguageInterface. It is not now.
ConfigurableLanguage gets its sort() from ConfigEntityBase. (which accesses the weight and label properties directly.)
Comment #3
yesct commentedoops. totally the wrong file. (I'll cancel that test)
here is the correct one.
Comment #6
yesct commentedcollecting other issues I think have delt with this sort.
Comment #7
yesct commentedmessed up the brackets.
Comment #8
alexpottIf we hint on the interface then this can be used to sort configurable languages too. Which will be super useful for #2107427: Regression: Language names should display in their native names in the language switcher block
Comment #9
alexpottLike so...
Comment #10
yesct commentedthanks.
read through the changes...
change to the sort to save the weights instead of getWeight each time. ok.
type hinting on the interface, k.
adds configurable language objects to the sort test. seems like a good idea to have a test that sorts an array made up of Language and ConfigurableLanguage. (not sure if we should add that in this issue, but seems fine, as before #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface we could not do it. Now we can and since ConfigurableLanguage's are now LanguageInterface things, and we are changing the Language::sort() seems like a good idea to extend the test coverage.)
I made some small changes to the data provider to keep the same pattern as the Language things had before, and keep the tests only testing what they were before (there was a test that had no ties in weight).
---
I dont understand why we have to make a new EntityType to use, instead of configurable_language.
Maybe the test is not really testing what would happen when sorting an array that has some ConfigurableLanguage.
Comment #12
yesct commentedrandom fail due to #2330751: Random test failures everywhere due to ->with(Request::create())
Parameter 0 for invocation Symfony\Component\Routing\Matcher\RequestMatcherInterface::matchRequest(Symfony\Component\HttpFoundation\Request Object (...)) does not match expected value.
Drupal\Tests\Core\UrlTest
Comment #13
yesct commentedComment #14
yesct commented(uploaded same patch again, so the test results can be preserved in case that is helpful for the random fail issue)
Comment #15
gábor hojtsyLooks good except:
Not an array sort anymore?
Comment #16
yesct commentedyeah, I thought of that, but it does sort an array of languages. :)
Comment #17
yesct commentedJust a little comment fix about types.
If we are ok with the mock in the test, then I guess this is ready.
Comment #18
yesct commentedafter berdir pointed out that this test lives in the place for core components, and that it was strange to be using something from a module,
I took out the configurablelanguage bit. that can go in its own test. #2334483: add test for sorting an array of languages that are Language and ConfigurableLanguage to show the sort() will work for configurable languages too.
maybe we should mock something that implements the language interface and add it too, which could be added here... but I think this is good enough to be ok for now, and we can expand it in other issue. #2334477: expand Language::sort() test coverage to show it works with other objects that implement the LanguageInterface
So.. I think we can agree on this. Get this in, then work on the others.
This will also unblock at least some things.
Comment #19
gábor hojtsyLooks good to me, we can expand with more tests later.
Comment #21
catchCommitted/pushed to 8.x, thanks!
Comment #22
gábor hojtsyThanks!