[wp-trac] [WordPress Trac] #30047: Trashed page forces 404 even if there are other rewrite rules to match
WordPress Trac
noreply at wordpress.org
Mon Oct 20 09:12:57 UTC 2014
#30047: Trashed page forces 404 even if there are other rewrite rules to match
---------------------------+-----------------------------
Reporter: etki | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Rewrite Rules | Version: 4.0
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Hi.
How to reproduce bug: create page with any slug you like, put it into a
trash, register custom post type with the same slug, visit archive page
and ensure it gives 404.
It occurs on the line 209 of wp-includes/class-wp.php:
{{{
foreach ( (array) $rewrite as $match => $query ) {
// If the requesting file is the anchor of the match, prepend it
to the path info.
if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 &&
$req_uri != $request )
$request_match = $req_uri . '/' . $request;
if ( preg_match("#^$match#", $request_match, $matches) ||
preg_match("#^$match#", urldecode($request_match),
$matches) ) {
if ( $wp_rewrite->use_verbose_page_rules && preg_match(
'/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
// this is a verbose page match, lets check to be
sure about it
if ( ! get_page_by_path( $matches[ $varmatch[1] ]
) )
continue; // here it is
}
// Got a match.
$this->matched_rule = $match;
break;
}
}
}}}
This chunk of code catches trashed page as a valid result, thus ending
rewrite rules search, but further code analyzes page and sees that is
trashed, producing error 404, while there may be more matching rewrite
rules after general rule for static pages.
Furthermore, get_page_by_path() doesn't analyze post status and may return
trashed page even if there is a live page around.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30047>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list