Getting a warking every time the cache is rebuilt.
The warning comes from ContentEntityDeriver ordering plugins by label, which are not strings but TranslatableMarkup objects. When these objects are rendered they're changed, and that is why uasort throws such warning.
Similar issue with token module, https://www.drupal.org/node/2670942
I think the solution would be not ordering at all these plug-ins, first of all because this is a backend operation, plug-ins are cached and they may be displayed in a different language, thus such ordering makes no sense.
I don't know if these labels are ever displayed, but if so, the ordering should be done when displaying them in a specific language, not here.
This is the offending line, which I would just remove from ContentEntityDeriver:
uasort($plugin_derivatives, array($this, 'compareDerivatives'));
Comment | File | Size | Author |
---|---|---|---|
#13 | 2758321-13--clean_up_derivers.patch | 9.07 KB | drunken monkey |
|
Comments
Comment #2
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedComment #3
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedHere is a patch to remove uasort from ContentEntityDeriver.php
Comment #4
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedComment #5
Jose Reyero CreditAttribution: Jose Reyero at Gronze.com commentedLooks good to me, however I am not sure whether there was a reason for this ordering... if this plug-in list was being displayed somewhere (?) maybe there should be some other reordering somewhere else in the UI.
Comment #6
drunken monkeyThanks a lot for reporting this problem and thanks for the patch!
You're right, sorting the arrays there doesn't really make any sense.
I've tried it, and for some reason the order still stays the same in the index edit form even without that line. However, to be sure, we should still add an explicit sort there when setting the options in the form.
Also, we don't need the
compareDerivatives()
method then anymore.Finally, I found some other weird stuff regarding our deriver classes, so I cleaned that up, too.
Comment #8
drunken monkeyThis should work better.
Comment #10
drunken monkeySame fix for the Views display deriver.
Comment #11
drunken monkeyComment #12
borisson_Comment #13
drunken monkeyThanks a lot for reviewing!
Attached a re-roll – if the test bot doesn't object, I'll commit it.
Comment #15
drunken monkeyOK, great.
Committed.
Thanks again to everyone!
Comment #17
andrezstar CreditAttribution: andrezstar commentedStill having the issue
Warning: uasort(): Array was modified by the user comparison function in Drupal\facets\Plugin\facets\facet_source\SearchApiDisplayDeriver->getDerivativeDefinitions() (line 61 of modules/contrib/facets/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php).
My stuff:
Drupal core 8.4.5
Bootstrap 8.x-3.10
Facets 8.x-1.0-beta2
Search API 8.x-1.7
Elasticsearch Connector 8.x-5.0-alpha2