When adding an entity query sort (addEntityQuerySort), the sort does not work when sorting on a field that is the same for all languages (non-translatable). In this case, the sort only works for the entity that has the default langcode. This is caused by the current langcode being added on the sort by default.

As the langcode is added as a condition by default in the NodeRepository, I propose we make the langcode an optional parameter in the "addEntityQuerySort" method. This way it can still be used when needed (eg. querying multiple languages and sorting on a specific language of a field).

Comments

wtrv created an issue. See original summary.

wtrv’s picture

Created patch for proposed solution.

wtrv’s picture

StatusFileSize
new537 bytes

New patch, adding the langcode as optional parameter in the sort array param.

jeroent’s picture

Status: Active » Needs review

  • JeroenT committed e27f816 on 2.0.x authored by wtrv
    Issue #3218846 by wtrv, JeroenT: Entity query sort should not provide a...
jeroent’s picture

Status: Needs review » Fixed

Committed and pushed to 2.0.x. Thanks!

wtrv’s picture

Status: Fixed » Needs work

It appears this patch does have some adverse effects on multilingual sites.
I propose we update the code so that the default behaviour does not change, but we have the option to disable or override the langcode when adding a sort.

wtrv’s picture

StatusFileSize
new603 bytes
wtrv’s picture

Status: Needs work » Needs review
wtrv’s picture

  • JeroenT committed 462ed85 on 2.0.x authored by wtrv
    Issue #3218846 by wtrv, JeroenT: Entity query sort should not provide a...
jeroent’s picture

Status: Needs review » Fixed

Committed and pushed to 2.0.x. Thanks!

Status: Fixed » Closed (fixed)

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