New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selector for field in nested repeater item wrongly matches pages where top-level repeater is empty #205
Comments
I can confirm this (as of 3.0.98) and am baffled it's one year since this report and nothing happened.... :( |
I've looked at this one out a couple times but haven't been able to figure it out. @somatonic your wording suggests you may know more about how to fix it than I do? If so please post more details. Otherwise, this issue will have to remain open until someone affected by the issue can assist with the debugging of it. |
Video of issue: |
Hmm, now that I'm looking at this with a fresh pair of eyes, if I simply added |
Another quirk of this issue: if you use "multi dot" syntax to attempt to match a field that is not even in the repeater the selector will match pages where the repeater is empty. So if field my_repeater does not contain the images field then this selector will match pages where my_repeater is empty. $results = $pages->find("my_repeater.images.description=foo");
That selector clause shouldn't be necessary since x.y.z=value by implication cannot (and should not) match a page where x is empty. |
I took a stab at debugging this issue and the problematic part seems to be this section of PageFinder. This section comes into play because the count the array of matching page IDs is zero (no pages match the subselector), and the result of this section in the case of my example above is I don't grasp everything that this section of code is doing, but it contains this comment...
...which sounds like the intention is to force a non-match. But if that's the case couldn't the non-match be forced directly by using |
More investigation... A selector This part seems to be saying a search for |
@jlahijani Thanks for the video, that was helpful to see. @Toutouwai I think you tracked it down! Nice job—thanks. It was that FieldtypeRepeater::getMatchQuery() that was converting an id=0 to a field.count=0, which isn't what we want here. The id=0 should instead force a non-match. I've pushed an update that corrects that. I think this fixes it except that I'm not 100% confident because I was never able to duplicate the "another quirk" you mentioned, that was always returning a no-match for me. |
Great, thanks @ryancramerdesign, that fixes all the cases I tested with. |
Short description of the issue
A selector for a field contained in a nested repeater (a repeater inside another repeater) wrongly matches pages where the top-level repeater field is empty.
Steps to reproduce the issue
Setup/Environment
The text was updated successfully, but these errors were encountered: