[wp-trac] [WordPress Trac] #64250: Refactor redirect_guess_404_permalink to use WP_Query instead of raw SQL
WordPress Trac
noreply at wordpress.org
Wed Feb 11 22:27:02 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
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):
* keywords: has-patch commit has-unit-tests needs-dev-note => has-patch
commit has-unit-tests needs-dev-note changes-requested
Comment:
@westonruter @spacedmonkey Sorry, I haven't had much opportunity to review
the proposed PR before now.
While I agree the query in `redirect_guess_404_permalink()` ought to be
cached, I'm not sure that adding a dedicated feature to `WP_Query` is an
appropriate approach.
If WordPress is to allow developers to specify the search position, then
that's the parameter that should be introduced, it `search_pos =>
start,end,none or whatever`.
We'll also need to make sure it is/isn't available to be set on the front
end, as appropriate, and include the variable in `WP` accordingly. With
tests for that too.
As an initial step to include performance of this query it could be stored
as a salted cache in the `post-queries` group.
It would also be good to consider the performance impact of caching the
current code vs using a `WP_Query` instance. `WP_Query` is a lot while the
current code is very little.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64250#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list