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.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
The documentation here says that "The size of the conditional is the size of its conditional array minus one, because one element is the conjunction." After getting some unexpected results though I stepped through the code and found that the conjunction is not in the conditions array that the count function is going through (please see screenshot).
As such to get the expected results we had to use the conditions() function to get the array of conditions and pass them through count() ourselves.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2961285-18-entity-query-condition-count-faulty.patch | 2.53 KB | pavlosdan |
Comments
Comment #2
pavlosdan CreditAttribution: pavlosdan commentedPlease find a patch with a test for this.
Comment #3
pavlosdan CreditAttribution: pavlosdan commentedUpdating status.
Comment #4
borisson_There is unneeded whitespace added in this patch that shouldn't be added.
Comment #5
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedUpdated patch to remove unneeded whitespace.
Comment #7
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedAdjusting the test.
Comment #9
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedAttaching patch with just the test. This should fail.
Comment #11
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedThe test failed as expected. Setting back to needs review for the patch in #7
Comment #12
hchonovI've took a look and I guess this is just a copy paste left over, as for normal DB queries this is still the case, but entity queries deal with the conjunction differently.
@pavlosdan, could you please re-upload the patch from #7 and only add a test for "OR" condition groups? It is clear that those are broken as well, but with only couple of more lines we get a complete coverage. Beside that this is ready to go for me.
Comment #13
hchonovComment #14
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedThanks @hchonov. Adjusting the tests to test the count of AND condition groups and OR condition groups.
Comment #15
volegerLooks good
Comment #16
volegerComment #17
hchonovI am sorry, but we don't really need two test methods for this. Could you please put them in the same test method? I am sorry if my previous comment misled you, I should've explicitly mention this.
Comment #18
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedApologies for misunderstanding. Merged the 2 methods :)
Comment #19
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedComment #20
hchonovThank you.
Comment #21
alexpottCommitted and pushed a4208fd3c8 to 8.7.x and 3f42b03bcf to 8.6.x. Thanks!
Backported to 8.6.x as a non-disruptive bugfix.
A couple of coding standard issues fixed on commit.