Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
This comment has been minimized.
This comment has been minimized.
|
@tellthemachines assuming that I’ll make sure all the tests pass, would you be interested in giving this a look-over? we had some failures due to reordering of the attributes on |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
the level of failure of PHPStan here to analyze this change is impressive, and yet I realize that somehow that’s the intended behavior, which is baffling that any imaginable type system for an object-oriented language would assume that method calls are pure and disconnected from internal state on their object. |
|
@westonruter here is another case where the following config change would improve the default effectiveness of the type checker. if we switched that, it would seem like the type check would actually lead us to consider cases we might assume a type is one thing when it could be more than one thing, which would be safety by default. the analysis of this PR is another example where the type checker is instructing us to enter defects into code and encouraging loss of trust in its utility. maybe we would have a big PR removing all those |
I've got two PRs open to explore two ends of this, the first one you'll hate and the second one I think you'll love:
|
Trac ticket: Core-66668. Follow-up to r64233. Attribute ordering in HTML is not guaranteed, but the PCRE pattern in `excerpt_remove_footnotes()` was hard-coded to expect this. The `wp_kses()` refactor exposed this as it happened to reorder attributes that are saved on footnote references in the block editor. This patch replaces the PCRE match in `excerpt_remove_footnotes()` with the HTML API and matching code to detect the intended pattern from the original implementation, making it more robust against lexical variations of equivalent HTML structure.
6c0d460 to
91dee96
Compare
|
|
||
| $footnote_opening = $processor->get_span(); | ||
|
|
||
| if ( ! $processor->next_token() ) { |
There was a problem hiding this comment.
The PHPStan errors can all be resolved in the short term via:
diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php
index 7e047c4808..34429f2b31 100644
--- a/src/wp-includes/html-api/class-wp-html-tag-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php
@@ -956,6 +956,8 @@ class WP_HTML_Tag_Processor {
* @since 7.1.0 Recognizes processing instructions.
*
* @return bool Whether a token was parsed.
+ *
+ * @phpstan-impure
*/
public function next_token(): bool {
return $this->base_class_next_token();Since \WP_HTML_Tag_Processor::parse_next_tag() and \WP_HTML_Tag_Processor::next_tag() both have this annotation, it's not really out of the norm. If we flip off rememberPossiblyImpureFunctionValues then they can all be removed together.
There was a problem hiding this comment.
I held back adding another goto. I will bite my tongue and add this and try to hide my shame.
cbravobernal
left a comment
There was a problem hiding this comment.
LGTM. I compared it with the old regex on several inputs, and it accepts other attribute orders, quotes and casing.
Not blocking: a test case with class before data-fn would fail with the old regex.
Attribute ordering in HTML is not guaranteed, but the PCRE pattern in `excerpt_remove_footnotes()` was hard-coded to expect a specific order. The `wp_kses()` refactor reorders attributes saved in footnote references from the block editor, triggering a failure to remove them from excerpts. This patch replaces the PCRE match in `excerpt_remove_footnotes()` with HTML API matching code, which detects the intended pattern from the original implementation, making it more robust against lexical variations of equivalent HTML structure. Developed in: #15917 Discussed in: https://core.trac.wordpress.org/ticket/66668 Follow-up to r64233. Props cbravobernal, dmsnell, tbshiki, westonruter. Fixes #66668. See #66208. git-svn-id: https://develop.svn.wordpress.org/trunk@65560 602fd350-edb4-49c9-b593-d223f7449a82
Attribute ordering in HTML is not guaranteed, but the PCRE pattern in `excerpt_remove_footnotes()` was hard-coded to expect a specific order. The `wp_kses()` refactor reorders attributes saved in footnote references from the block editor, triggering a failure to remove them from excerpts. This patch replaces the PCRE match in `excerpt_remove_footnotes()` with HTML API matching code, which detects the intended pattern from the original implementation, making it more robust against lexical variations of equivalent HTML structure. Developed in: WordPress/wordpress-develop#15917 Discussed in: https://core.trac.wordpress.org/ticket/66668 Follow-up to r64233. Props cbravobernal, dmsnell, tbshiki, westonruter. Fixes #66668. See #66208. Built from https://develop.svn.wordpress.org/trunk@65560 git-svn-id: http://core.svn.wordpress.org/trunk@64633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: Core-66668.
Follow-up to r64233.
Attribute ordering in HTML is not guaranteed, but the PCRE pattern in
excerpt_remove_footnotes()was hard-coded to expect this. Thewp_kses()refactor exposed this as it happened to reorder attributes that are saved on footnote references in the block editor.This patch replaces the PCRE match in
excerpt_remove_footnotes()with the HTML API and matching code to detect the intended pattern from the original implementation, making it more robust against lexical variations of equivalent HTML structure.