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
findMany() combined with getPage() gives pages whose parents are (incorrectly) NullPage #1549
Comments
PW forum member @matjazp suggests the problem may have been introduced with the commit “Fix issue https://github.com/processwire/processwire-issues/issues/1495,” specifically with the |
Thanks @erikmh @adrianbj I've pushed a fix for this issue. Please let me know if you still observe any issues. Note that I would recommend using findMany() only in cases where you will be iterating the |
Looks good to me, thanks! |
This is beyond excellent, @ryancramerdesign — I’m stunned by your speed in fixing this! I’ve taken your two-line change and directly replicated it on my server (running 3.0.197), replaced my find() with findMany(), and can confirm that everything’s working exactly as expected. I also installed the current dev version from GitHub and confirmed it that way. Thanks for your advice regarding the use of findMany(): that’s exactly how I’m using it. It’s currently averaging only about 5% faster than find() in the real world on my site; but as the site gets larger, I expect that difference will increase. |
@erikmh Thanks for testing it out and confirming it works. While looking into this, I did also find some optimizations I can make with this too so I'll be committing those later today or tomorrow. |
Short description of the issue
Page instances created by findMany() followed by getPage() believe they have no parent.
Expected behavior
If one gets a set of pages with findMany() and then iterates through them, getPage() should yield page instances that are aware of their parents.
Actual behavior
If one gets a set of pages with findMany() and then iterates through them, getPage() yields page instances that are ignorant of their parents; their parents are instead NullPages.
Optional: Screenshots/Links that demonstrate the issue
PW forum user @adrian has shown the issue well. The first Tracy dump shows getPage() working properly inside a find() with page 1023 having a parent of '/'; the second Tracy dump shows getPage() yielding the same page that doesn’t know about its parent:
Optional: Suggestion for a possible fix
Forum user @kongondo has speculated that this may be a result of this commit, which deals with findRaw()->parent — though if I’m reading things correctly, those changes came in 3.0.193, whereas this behavior is new in 3.0.192.
Steps to reproduce the issue
Setup/Environment
Server Details
Server Settings
GD Settings
iMagick Settings
Module Details
The text was updated successfully, but these errors were encountered: