[wp-trac] [WordPress Trac] #56991: Update to get_page_by_title in 6.1 changes WHERE clause order

WordPress Trac noreply at wordpress.org
Thu Nov 3 22:56:55 UTC 2022


#56991: Update to get_page_by_title in 6.1 changes WHERE clause order
--------------------------+-----------------------------
 Reporter:  Bjorn2404     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The recent update to the `get_page_by_title()` function in WordPress v6.1
 appears to have changed the order in which posts are queried. Steps to
 replicate as follows:

 * Start from WP 6.0
 * Create a page called "test"
 * Call get_page_by_title()
 * Receive expected post ID
 * Create another page called "test"
 * Call get_page_by_title()
 * Still receive the first one (expected)
 * Delete first page
 * Call get_page_by_title() again
 * Receive the latest page (second) ID
 * Update to WP 6.1
 * Call get_page_by_title() again
 * Receive first page ID in the trash

 The underlying cause looks to be the addition of `get_post_stati()`, which
 is resulting in all post statuses being included in the WHERE clause.

 Bug was discovered after a production site was updated to 6.1 and the home
 page led to a 404.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56991>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list