Skip to content

Commit

Permalink
fix: restore 404 handling to parse_request()
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Mar 7, 2023
1 parent 0114372 commit c443643
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Data/NodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,9 @@ public function parse_request( string $uri, $extra_query_vars = '' ) {
// Fetch the rewrite rules.
$rewrite = $wp_rewrite->wp_rewrite_rules();

$error = '404';
if ( ! empty( $rewrite ) ) {
// If we match a rewrite rule, this will be cleared.
$error = null;
$error = '404';
$this->wp->did_permalink = true;

$pathinfo = ! empty( $uri ) ? $uri : '';
Expand Down Expand Up @@ -460,9 +459,16 @@ public function parse_request( string $uri, $extra_query_vars = '' ) {
// Substitute the substring matches into the query.
$query = addslashes( \WP_MatchesMapRegex::apply( $query, $matches ) ); // @phpstan-ignore-line

$this->wp->matched_query = $query;

// Parse the query.
parse_str( $query, $perma_query_vars );

// If we're processing a 404 request, clear the error var since we found something.
// @phpstan-ignore-next-line
if ( '404' == $error ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
unset( $error );
}
}
}

Expand Down

0 comments on commit c443643

Please sign in to comment.