[wp-trac] [WordPress Trac] #56802: Query: Post IDs cached for search and other 'LIKE' queries are unreachable

WordPress Trac noreply at wordpress.org
Thu Oct 13 00:49:10 UTC 2022


#56802: Query: Post IDs cached for search and other 'LIKE' queries are unreachable
--------------------------------------+--------------------------
 Reporter:  dlh                       |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  6.1
Component:  Query                     |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------

Comment (by dlh):

 It looks like there's a second scenario where placeholders can interfere
 with the cache key: During search queries, the prepared search terms are
 included with the `search_orderby_title` query variable, e.g.

 {{{
 'search_orderby_title' => [
         'wp_posts.post_title LIKE
 \'{8b8e7d5ae92dd4a249779814885fb4bdb2051b6bef993769f8b4352e46de15ad}hello{8b8e7d5ae92dd4a249779814885fb4bdb2051b6bef993769f8b4352e46de15ad}\'',
         'wp_posts.post_title LIKE
 \'{8b8e7d5ae92dd4a249779814885fb4bdb2051b6bef993769f8b4352e46de15ad}world{8b8e7d5ae92dd4a249779814885fb4bdb2051b6bef993769f8b4352e46de15ad}\'',
 ]
 }}}

 so even if placeholders are removed from `$request`, they'll still be in
 `$cache_args`.

 It seems pretty safe to me to unset `$cache_args['search_orderby_title']`
 along with `suppress_filters`, `fields`, etc. Or,
 `wpdb::remove_placeholder_escape()` could be run against these additional
 strings like it is in the PR.

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


More information about the wp-trac mailing list