[wp-trac] [WordPress Trac] #50873: Search query parameter causes 404 on pagename match rules

WordPress Trac noreply at wordpress.org
Fri Aug 7 15:58:28 UTC 2020


#50873: Search query parameter causes 404 on pagename match rules
--------------------------+------------------------------
 Reporter:  MikeNGarrett  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  5.4.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+------------------------------

Comment (by daxelrod):

 In discussing with @MikeNGarrett and @kshaner the 404 behavior originates
 from class-wp.php:handle_404() which receives a query with no posts.

 Tracing backwards, in class-wp-query.php:parse_query() the is_search state
 should only be triggered if attachment/p/postname/pagename is not set, but
 class-wp-query.php:get_posts() only looks for `strlen( $q['s'] )`
 (ignoring if it were a singular query). The logic was resulting in a query
 that was both selecting a post, and searching at the same time. The query
 (typically) selects 0 posts, which results in the 404.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50873#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list