[wp-trac] [WordPress Trac] #16557: Ability to disable redirect_guess_404_permalink()
WordPress Trac
noreply at wordpress.org
Sat Oct 5 02:47:54 UTC 2019
#16557: Ability to disable redirect_guess_404_permalink()
------------------------------------+-----------------------------
Reporter: msafi | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Canonical | Version: 3.1
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+-----------------------------
Comment (by apedog):
I think a new short-circuit filter {{{'do_redirect_guess_404_permalink'}}}
at the start of {{{redirect_guess_404_permalink()}}} is the way to go.
The filter should return {{{false}}} (diable auto-guess), {{{true}}}
(continue with core implementation) or string (short-circuit core
implementation and return custom redirect string).
This would allow for implementing more robust and/or more performant
algorithms (bypass the costly {{{post_name LIKE %s}}} query mentined by
@DrLightman)
This would also allow for disabling the 404 redirect altogether for strict
compliance with HTTP (@neonkowy, @laternastudio)
One could still implement a 404 redirect mechanism - say one that
redirects {{{/slug}}} to {{{story/slug}}} but does not auto-correct to
{{{/slug-2}}}.
Or a mechanism that only redirects to posts and pages but not to
attachments (a personal pet-peeve).
+1 for having a checkbox in the permalinks settings page to disable auto-
guessing.
+1 for having auto-guess disabled by default. It's confusing. It's
unpredictable. It's a nightmare. More hassle than it's worth, really.
--
Taking a broader look, I think {{{redirect_canonical}}} is overdue for a
re-write ( I mean,{{{?p=123}}} => {{{?page_id=123}}} really? why? why??
{{{?p=123}}} is literally the canonical shortlink provided by WordPress
itself - {{{wp_get_shortlink}}}. Why would {{{redirect_canonical}}} change
that after the query has been made?)
Adding this filter seems like a good first iteration on this long overdue
change. It will allow for some new (perhaps better, more customizable)
implementations of the auto-guess in the wild. And it's safe. It will not
break BC. And it might pave the way for a more robust modern routing
system in future WordPress releases.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/16557#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list