[wp-trac] [WordPress Trac] #50871: When exact is true and orderby set to relevance, there is a DB error on search results page

WordPress Trac noreply at wordpress.org
Fri Aug 7 12:52:45 UTC 2020


#50871: When exact is true and orderby set to relevance, there is a DB error on
search results page
------------------------------------+------------------------------
 Reporter:  5um17                   |       Owner:  (none)
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Query                   |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------

Comment (by SergeyBiryukov):

 Thanks for the ticket!

 > IMHO, we should not call `parse_search_order()` when
 `search_orderby_title` is empty regardless of `orderby`.

 As far as I can tell, this is already the case in the current condition:
 {{{
 if ( ! empty( $q['search_orderby_title'] )
         && ( empty( $q['orderby'] ) && ! $this->is_feed )
                 || ( isset( $q['orderby'] ) && 'relevance' ===
 $q['orderby'] )
 ) {
         $search_orderby = $this->parse_search_order( $q );
 }
 }}}

 `$this->parse_search_order( $q )` is only called if:
 * `$q['search_orderby_title']` is not empty.
 * AND either `$q['orderby']` is empty and this is not a feed, OR
 `$q['orderby']` is set to `relevance`.

 If `$q['search_orderby_title']` is empty, the first part of the condition
 is not satisfied, so `::parse_search_order()` is not called.

 So the analysis seems correct, but it seems like that patch won't work as
 expected.

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


More information about the wp-trac mailing list