[wp-trac] [WordPress Trac] #64250: Refactor redirect_guess_404_permalink to use WP_Query instead of raw SQL

WordPress Trac noreply at wordpress.org
Tue Feb 17 16:03:26 UTC 2026


#64250: Refactor redirect_guess_404_permalink to use WP_Query instead of raw SQL
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
                                                 |  spacedmonkey
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  7.0
Component:  Permalinks                           |     Version:  2.3
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch commit has-unit-tests      |     Focuses:
  needs-dev-note changes-requested               |  performance
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 Thanks for your feedback @peterwilsoncc

 I did consider just adding caching here. This issue was found because I am
 working on a site that has around 2.4 million posts and 1+ million
 attachments. The like search here, simply falls over. So it is best for a
 query of that size to be punted off to a search provider like elastic
 search. There are already a number of drop-in solution for adding ES or
 other scalable search solution / database to WP_Query. So WP_Query feels
 like a good fit here.

 I like the idea of adding `search_pos` and having these options.
 - anywhere so %s%
 - start %s
 - end %s.

 None does not make sense here, we already have `exact` parameter, that
 feel like that.

 Some ideas for naming

 `'search_match_type' => 'prefix' | 'suffix' | 'contains'`

 `'search_like' => 'left' | 'right' | 'both'`

 `'search_position' => 'start' | 'end' | 'anywhere'`

 We could add it to WP, not sure in the value of that, but I am not against
 it.

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


More information about the wp-trac mailing list