[wp-trac] [WordPress Trac] #56991: Update to get_page_by_title in 6.1 changes WHERE clause
WordPress Trac
noreply at wordpress.org
Mon Nov 7 08:27:10 UTC 2022
#56991: Update to get_page_by_title in 6.1 changes WHERE clause
--------------------------+---------------------
Reporter: Bjorn2404 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1.1
Component: General | Version: 6.1
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+---------------------
Comment (by spacedmonkey):
After some more testing, I discovered the issue. I have a PR
[https://github.com/WordPress/wordpress-develop/pull/3575 here].
The issue is the order by. Instead of defining order date / id, simple
pass 'none' as orderby field. Resulting query.
{{{
SELECT wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.post_title = 'test'
AND wp_posts.post_type = 'page'
AND ((wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'trash'
OR wp_posts.post_status = 'auto-draft'
OR wp_posts.post_status = 'inherit'
OR wp_posts.post_status = 'request-pending'
OR wp_posts.post_status = 'request-confirmed'
OR wp_posts.post_status = 'request-failed'
OR wp_posts.post_status = 'request-completed'
OR wp_posts.post_status = 'private'))
LIMIT 0, 1
}}}
Compared to 6.0
{{{
SELECT ID
FROM wp_posts
WHERE post_title = 'test'
AND post_type = 'page'
}}}
In my manual testing, I get the same result now for both queries.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56991#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list