Repository navigation
Editor: Ignore unsupported duotone attribute types - #14286
yotatameguchi-boop wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @yotatameguchi-boop. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
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. |
westonruter
left a comment
There was a problem hiding this comment.
Actually, I see the code was introduced by @tellthemachines in d966798. So maybe she can review as well.
There was a problem hiding this comment.
Thanks for checking this in PhpStorm as well! With the early type guard, unsupported attribute values return unchanged and every remaining branch assigns $filter_id.
| $is_preset = is_string( $duotone_attr ) && self::is_preset( $duotone_attr ); | ||
| $is_css = is_string( $duotone_attr ) && ! $is_preset; | ||
| $is_custom = is_array( $duotone_attr ); | ||
| if ( ! is_string( $duotone_attr ) && ! is_array( $duotone_attr ) ) { |
There was a problem hiding this comment.
Hello! I think we'd need to sync Gutenberg's copy as well lib/class-wp-duotone-gutenberg.php
There was a problem hiding this comment.
Thanks for pointing out the Gutenberg copy! I have opened WordPress/gutenberg#84801 to sync the early type guard and exhaustive branches, with coverage for the four unsupported attribute values. The existing isset( $filter_id ) guard in Gutenberg is preserved.
Validation: all 27 duotone tests (27 assertions), Gutenberg PHPCS for both changed PHP files, and the production build pass. PHP syntax checks also pass on PHP 7.4 and 8.3. The Gutenberg PR includes a backport-changelog entry linking it to this Core PR.
|
Thanks for the ping, @westonruter. I checked for overlaps. #14262 cleans theme.json preset definitions in I was just checking against #14262, which drops invalid types by the time they get to the loop that's changed in this PR. |
I just committed that PR years ago, didn't actually write it 😅 |
Still worth making this change IMO, if for no other reason than it makes the code a little more readable. |
|
Thanks @tellthemachines for reviewing and clarifying the history! Agreed: making the supported types explicit and the remaining branches exhaustive improves readability even where the upstream sanitization already filters invalid values. The corresponding Gutenberg change is in WordPress/gutenberg#84801, which you have also tested and approved. Thanks for checking both implementations! |
|
The corresponding Gutenberg change has now been merged: WordPress/gutenberg#84801 (96a5cfaaabd629d5908a1d17b0c3bf7683343f36). This completes the Gutenberg sync requested above. Thanks everyone for the reviews and testing! |
|
@yotatameguchi-boop would you like to create a wordpress.org account so we can give you props on the commit? |
|
Thanks @tellthemachines! My WordPress.org username is |
|
Closing as committed in https://core.trac.wordpress.org/changeset/64493. Thanks everyone! |

When
style.color.duotoneis a boolean or a number,WP_Duotone::render_duotone_support()reachesadd_class()with an undefined$filter_id. Return the original block HTML for attribute types other than string or array, and make the remaining branches exhaustive using the existing early return for blocks without local or global duotone settings.Add regression coverage for
false,true, an integer and a float, and regenerate thevariable.undefinedPHPStan baseline to remove the resolved occurrence.Trac ticket: https://core.trac.wordpress.org/ticket/65817
Validation on PHP 8.3:
Undefined variable $filter_id.vendor/bin/phpunit --group block-supports: 449 tests, 605 assertions pass.vendor/bin/phpstan analyse --memory-limit=2G: no errors.git diff --check: pass.AI assistance: OpenAI Codex generated the code, regression tests and PR description.