Closed danielbachhuber closed 2 years ago
Hey @danielbachhuber! I saw the update! Thank you!
But it still doesn't work for me.
So the page
post type is hierarchical and when the page
posts are queried for the "Edit pages" admin page (/wp-admin/edit.php?post_type=page
), core sets the fields
query parameter to id=>parent
.
As seen here: https://github.com/WordPress/WordPress/blob/9131d74641c4c857a1bc0a7de8a7b3abfdc561f3/wp-admin/includes/post.php#L1232
So our issue comes when searching pages in the admin.
In this plugin's posts_pre_query
filter (that you edited), if id=>parent
is set, the filter maps the posts array of WP_Post objects to an ID (key) > parent ID (value) array and returns that array to define $this->posts
in the core query.
So in the core query, when id=>parent
is set, it loops through the posts array and needs access to each post's ID
and post_parent
property. Which is not available because this plugin's posts_pre_query
removed them in its mapping.
Core code is here: https://github.com/WordPress/WordPress/blob/9131d74641c4c857a1bc0a7de8a7b3abfdc561f3/wp-includes/class-wp-query.php#L3057-L3075
So this breaks our page search query and I'm left wondering if there is something in our environment causing this issue, but in examining the code in relation to this plugin, along with a bit of localized debugging, it seems fairly obvious to me that the plugin is the issue.
I would very much welcome and appreciate your insight/thoughts.
So in the core query, when
id=>parent
is set, it loops through the posts array and needs access to each post'sID
andpost_parent
property. Which is not available because this plugin'sposts_pre_query
removed them in its mapping.
Dang. That does seem incorrect. I was able to reproduce the failure with ef9a574ab9e20aeb98de6a23efd3be0d5836d124
I've added a fix with 9c9f113a7523c58f141434905af8cca212891e95 and tagged v2.3.2.
Can you see if this fixes your issue? If it doesn't, can you share more detail about the buggy behavior you're experiencing, and the debugging you've done?
Your fix works! Thank you!
😅 Awesome!
Thanks for your help tracking it down 😊
From #521