Skip to content

fix: ensure base_convert() is type int before division - #68389

Merged
westonruter merged 3 commits into
WordPress:trunkfrom
justlevine:fix/baseconvert-division
Oct 25, 2026
Merged

westonruter merged 3 commits into
WordPress:trunkfrom
justlevine:fix/baseconvert-division

Conversation

@justlevine

@justlevine justlevine commented Dec 30, 2024 •

Copy link
Copy Markdown
Contributor

What?

This PR fixes several issues of string-number division in duotone-related functionality, due to the direct use of base_convert() in the operation (which returns a numeric string).

Why?

While this issue was surfaced by PHPStan (via #66693) it can be remediated independently as part of #66598

How?

absint() was used over casting for readability, since these are inline mathematical expressions.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@Mamaduka Mamaduka added the [Type] Code Quality Issues or PRs that relate to code quality label Jan 14, 2025
@justlevine
justlevine force-pushed the fix/baseconvert-division branch from a006518 to 88ffc64 Compare April 18, 2025 22:53
westonruter and others added 2 commits October 24, 2026 21:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hex strings are already constrained by the regular expressions to
non-negative values, so `absint()` adds nothing over a plain integer cast.
Using `(int)` matches the adjacent `base_convert()` calls and keeps
`WP_Duotone_Gutenberg::colord_parse_hex()` identical to
`WP_Duotone::colord_parse_hex()` in WordPress core, which made the same
fix in r61247.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@westonruter

Copy link
Copy Markdown
Member

🤖 Comment by Claude Opus 5.5

Trunk was merged in, and absint() was replaced with (int) in f3a57d5. The behavior is identical, since the regex limits the values to 0–255. The cast matches the adjacent base_convert() calls and makes WP_Duotone_Gutenberg::colord_parse_hex() identical to core's WP_Duotone::colord_parse_hex(), which made the same fix in r61247 (Core-64238). This resolves the three binaryOp.invalid errors reported at PHPStan level 5.

@westonruter westonruter added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Oct 25, 2026
@westonruter
westonruter merged commit ab4b78b into WordPress:trunk Oct 25, 2026
87 of 88 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants