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.
The EntityFieldQuery class defines a public property called 'orderedResults', however the property is never used. Instead, a nonexistant property called 'ordered_results' is used.
Comments
Comment #1
loganfsmyth CreditAttribution: loganfsmyth commentedHere's the quick fix, since it's only used in one place.
This is also an issue with D7.
Comment #2
chx CreditAttribution: chx commented#1: efq-ordered-results-case-1292930-1.patch queued for re-testing.
Comment #4
bxtaylor CreditAttribution: bxtaylor commentedRolled this against latest code. Location of the file has changed since OP.
Comment #5
chx CreditAttribution: chx commentedThanks for the reroll, could you please amend existing tests to check for this?
Comment #6
bxtaylor CreditAttribution: bxtaylor commentedI'd love to, although I'll need a little guidance - it'll be the first tests I've written.
I'll take a few days to catch up on testing documentation and get back to this. Seems to be no rush here.
My first question, though: am I looking to amend EntityFieldQuery.php?
Thanks, chx.
Comment #7
bxtaylor CreditAttribution: bxtaylor commentedErr, I mean EntityFieldQueryTest.php.
Comment #8
chx CreditAttribution: chx commentedYes, you are in the right file, I would probably patch up assertEntityFieldQuery.
Comment #9
disasm CreditAttribution: disasm commentedHere's a reroll. The functionality of ordered_results has since changed to be ids instead of partial_entities. Tests coming soon...
Comment #11
ACF CreditAttribution: ACF commented#9: drupal-efq_ordered_results-1292930-9.patch queued for re-testing.
Comment #13
ACF CreditAttribution: ACF commentedJust a reroll.
Comment #15
disasm CreditAttribution: disasm commented#13: 1292930-ordered_results-drupal_efq-13.patch queued for re-testing.
Comment #16
disasm CreditAttribution: disasm commentedattached is a patch with a test that verifies $orderedResults is not empty after running execute on an EntityFieldQuery with an entityOrderBy called prior to execute.
Comment #17
Berdir16: drupal-ordered_results-1292930-16.patch queued for re-testing.
Comment #19
David_Rothstein CreditAttribution: David_Rothstein commentedI just marked #2239355: pointless assignment in EntityFieldQuery::finishQuery() as a duplicate.
A couple quick comments on the patch:
- Since $this->ordered_results already exists (and is a public property by default) shouldn't we leave it around as a duplicate of $this->orderedResults for backwards compatibility? (And document it as a property on the class also.)
- It would be better if the test verified that the contents of $query->orderedResults were actually correct (i.e. in the correct order) rather than just that the variable is non-empty.
Comment #20
BerdirComment #21
Rok Žlender CreditAttribution: Rok Žlender commentedIs this still a valid issue? I couldn't find any mention of ordered_results in 8.0.x or anything similar to ordered_results.
Comment #22
mfernea CreditAttribution: mfernea commentedI also think that this issue is no longer relevant. No occurences of "ordered_results" in code.
Comment #23
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedThis is still an issue in Drupal 7.x core. It's a typo in a variable name, but some people may be using ordered_results instead of orderedResults, since it's a typo in the code. Documentation for it still says it's orderedResults. I don't see why we don't fix this, since it's an obvious typo in either the code or the documentation. Or is there another bug for this?
Comment #24
sosyuki CreditAttribution: sosyuki commentedBecause some people using ordered_results in code.
Comment #25
stefan.r CreditAttribution: stefan.r commentedComment #26
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commented@sosyuki not really that good of an excuse. orderedResults never would have worked so changing the comment and the official way to "ordered_results" (or both) would be the fix.
Comment #27
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedThis is throwing a deprecated message on PHP 8.2:
I think we need to update the
execute()
function doc block and rename the public property$orderedResults
(which never worked and it is always empty) to$ordered_results
.Comment #28
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedUploading the patch with this approach. I do not think we can do the opposite, as people are already using the
$ordered_results
in the code, so we need to preserve that. It is questionable if we have to preserve the currently non-working property$orderedResults
, but I think it is not needed (is it possible someone is using it despite that is always empty?).Comment #30
mcdruidDraft CR: https://www.drupal.org/node/3322453
Thanks!