alleyinteractive / alleyinteractive/rewrite-testing

False negatives when a site is using verbose page rules

Offen
#4 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
awaiting verification bug
Vorherrschende Sprache
PHP
Sterne
44
Forks
4
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

If a site is using a permalink structure which begins with `%postname%`, `%category%`, `%tag%`, or `%author%`, it'll trigger verbose page rewrite rules ([source](https://github.com/WordPress/WordPress/blob/4.1.1/wp-includes/rewrite.php#L2089-L2093)).

Verbose page rewrite rules means that `WP::parse_request()` will use `get_page_by_path()` if a given rewrite rule is a `pagename` rule ([source](https://github.com/WordPress/WordPress/blob/4.1.1/wp-includes/class-wp.php#L204-L216)) to check that a matching page exists, rather than simply allowing the rewrite rule to match.

This means a `pagename` rule will not match if the page doesn't actually exist on the site, and it'll allow a subsequent rewrite rule to match. This is the only time where a matching rewrite rule can fall through and allow a subsequent rule to match.

Rewrite Rule Testing doesn't take this into account, therefore its behaviour doesn't match WordPress' behaviour when matching a rewrite rule to its query.

The net result is that you can have rewrite tests which Rewrite Rule Testing falsely match to a page rewrite rule, when it should be matching WordPress core's behaviour by checking the match with `get_page_by_path()` and falling back to a subsequent rule if it doesn't exist.

**tl;dr** Rewrite Rule Testing reports false negatives because its logic doesn't match core's.

Fix coming up shortly.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.