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.
Add support for LIKE and IN operators in EntityFieldQuery condition for flag name.
Comments
Comment #1
bulat CreditAttribution: bulat commentedComment #2
bulat CreditAttribution: bulat commentedComment #3
joachim CreditAttribution: joachim commentedWhat's the difference between the two patches you've posted?
Comment #4
bulat CreditAttribution: bulat commentedNo difference, second has my drupal username and email. Unfortunately I don't know of a way to delete a comment here.
Comment #5
joachim CreditAttribution: joachim commentedAh right. Will review when I have a bit more time then :)
(For future reference, you can edit one of your own comments, for instance to say that it's posted in error.)
Comment #6
bulat CreditAttribution: bulat commentedGood tip, thanks
Comment #7
joachim CreditAttribution: joachim commentedI'm actually rather confused by what this patch is changing:
Why is this getting removed?
I don't understand what this is all about. Needs comments!
Class needs a docblock, and so do its functions and properties. Spacing is needed between them.
Also, your patch has a lot of whitespace issues!
Comment #8
bulat CreditAttribution: bulat commentedWell, I guess I will try to explain it here before adding comments and fixing whitespace.
1. code is removed because it is not working for LIKE operator.
2.
flag_query_flagging_flag_names_alter
joins query object build byEntityFieldQuery
toflag
table and adds condition from 'bundle' of EFQ to name field offlag
table.Comment #9
joachim CreditAttribution: joachim commented> 1. code is removed because it is not working for LIKE operator.
Yes, but it's needed for other reasons!
Comment #10
bulat CreditAttribution: bulat commentedI wrote test to show that it works without this code.
Comment #11
bulat CreditAttribution: bulat commentedTrailing spaces removed.
Comment #12
joachim CreditAttribution: joachim commentedGetting there!
Still needs comments. As a maintainer, I want to be able to look at this code in a year's time when I get a bug report about it, and read the comments to understand what it does -- not interpret the code like I'm a human PHP compiler!
This is no longer strictly true.
These lines seem to be:
- adding the query tag for hook_query_TAG_alter() to act on
- adding metadata for that function to find.
They should also go in the more logical order of adding the tag first, then the things it needs.
This should say that it does the work for allowing fids to be used in EFQs.
These lines are pulling the metadata out of the query that we stashed back in flag_entity_query_alter().
This joins onto the {flag} table so we can add the query conditions on the flag fid.
Comment #13
bulat CreditAttribution: bulat commentedComments added.
Comment #14
bulat CreditAttribution: bulat commented@joachim is there any chance for this patch to be integrated?
Comment #15
joachim CreditAttribution: joachim commentedYup, sorry for the delay.
I fixed a few things:
- added @see statements to the two hook implementations, as they work in tandem
- missing docblocks on class and methods in the test
- indentation problems
- typos
- removed the private $flag1 in the test class, as there's also $flag2 and $flag3 which aren't declared, so it seems inconsistent.
Here's the modified patch, which I've committed.
Thanks!
git commit -m "Issue #2021191 by bulat: Added support for LIKE and IN operators on flagging entity bundle condition in EntityFieldQuery." --author="bulat "
Comment #16
bulat CreditAttribution: bulat commentedCool, thanks!