Opened 10 years ago
Closed 10 years ago
#30047 closed defect (bug) (duplicate)
Trashed page forces 404 even if there are other rewrite rules to match
Reported by: | etki | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0 |
Component: | Rewrite Rules | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Duplicate of #21970.