alleyinteractive / alleyinteractive/rewrite-testing

False negatives when a site is using verbose page rules

オープン
#4 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
awaiting verification bug
主要言語
PHP
スター
44
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。