Repository navigation
Document the known bugs in the deprecated duotone functions - #68397
westonruter merged 4 commits into
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
5986eb3 to
80c5ffa
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revert the strict comparison change in `gutenberg_tinycolor_bound01()` and instead ignore the PHPStan errors in the deprecated duotone functions, with a reason for each. Fixing the comparison alone does not make the function behave as in TinyColor: it would turn '1.0' into '100%', but the percentage check further down never matches, because `$n` has already been cast to a number by then. So with a max of 255, '1.0' would go from 0.0039 to 0.3922, rather than to 1. Since these functions have been deprecated since 6.3.0 and are only called by each other, the bugs are documented where PHPStan reports them rather than fixed: * `gutenberg_tinycolor_bound01()`: '1.0' is never treated as 100%, and percentages are never converted. * `gutenberg_tinycolor_hsl_to_rgb()`: the achromatic branch never runs, though the general formula yields the same gray. * `gutenberg_tinycolor_string_to_rgb()`: an unrecognized color string returns null. * `gutenberg_render_duotone_support()`: the required `$wp_block` argument is not passed, so it throws an `ArgumentCountError`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`gutenberg_render_duotone_support()` called `WP_Duotone_Gutenberg::render_duotone_support()` without its required `$wp_block` argument, so it threw an `ArgumentCountError`. Core fixed its `wp_render_duotone_support()` in r56226 by creating a `WP_Block` from the parsed block, so do the same here instead of ignoring the PHPStan error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Comment by Claude Opus 5.5
The comparison fix alone does not make
A faithful port would also need the percentage to be detected before the cast, and
The fifth, Core's deprecated copies of the other three functions in |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. 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:
Updated as activity occurs, without notifying anyone named here. Add the |
What?
This PR fixes an issue in
gutenberg_tinycolor_bound01()where anintis strict-compared to afloat, resulting in an always-false comparison.Why?
While this issue was surfaced by PHPStan (via #66693) it can be remediated independently as part of #66598
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast