[wp-trac] [WordPress Trac] #35031: wp_old_slug_redirect() in 4.4 redirecting existing posts
WordPress Trac
noreply at wordpress.org
Wed Dec 16 02:42:09 UTC 2015
#35031: wp_old_slug_redirect() in 4.4 redirecting existing posts
-------------------------------------------------+-------------------------
Reporter: douglsmith | Owner: pento
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.4.1
Component: Query | Version: 4.4
Severity: critical | Resolution:
Keywords: has-patch needs-unit-tests needs- | Focuses:
testing |
-------------------------------------------------+-------------------------
Comment (by pento):
So, here's a quick order of operations, so that I don't have to keep re-
reading all of this:
* From `wp-blog-header.php`, `wp()` is called, which calls `$wp->main()`.
* `$wp->main()` sets up the query, which looks for the post that matches
the slug.
* `$wp->main()` then calls `$wp->handle_404()`, which will set `is_404()`
to true when the page doesn't exist. It *doesn't* set it to true when the
URL is a feed, because lol.
* We go back to `wp-blog-header.php`, which loads `template-loader.php`,
which does the `template_redirect` action, which `wp_old_slug_redirect()`
is hooked into.
Now, the important bit here is that part of the point of [34659] was to
handle URL endpoints, like `/feed/`. Feeds don't have a 404, though, so we
can't just re-add the `is_404()` check. Instead, feeds are handled more
intelligently inside `wp_old_slug_redirect()`. We want to maintain that
logic.
Because we know if a post does or doesn't exist (as determined by
`$wp->handle_404()`), then we know that, after checking `is_feed()`, and
`is_404()` is not true, we're looking at a real post, and we shouldn't
redirect.
And so, we have [attachment:35031.2.diff].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35031#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list