Opened 2 months ago
Last modified 5 weeks ago
#59496 new defect (bug)
Duotone undefined index/array key warning
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.3 |
Component: | Editor | Keywords: | has-patch has-testing-info needs-unit-tests |
Focuses: | Cc: |
Description
When using a hsl() value to create duotones in theme.json, such as:
"duotone": [ { "colors": ["hsl(0, 0%, 35%)", "hsl(0, 0%, 95%)"], "slug": "gray-scale", "name": "Gray Scale" } ]
PHP will throw a warning about an undefined index (in PHP 7.4) or undefined array key (in PHP 8+) when a block uses that duotone on a page.
The exact warning is:
"PHP Warning: Undefined array key "" in ../wp-includes/class-wp-duotone.php on line 212"
Change History (2)
This ticket was mentioned in PR #5351 on WordPress/wordpress-develop by jacobcassidy.
2 months ago
#1
#2
@
5 weeks ago
- Component changed from General to Editor
- Keywords has-testing-info needs-unit-tests added
- Milestone changed from Awaiting Review to 6.5
- Version changed from trunk to 6.3
Hello @jacobcassidy,
Welcome to WordPress Core's Trac :) Thank you for reporting this issue.
The code in question was introduced in 6.3.0 via #58555 / [56101]. Thus, I updated the Version
to reflect when it was introduced.
Moving this ticket into 6.5. Adding needs-unit-tests
for the patch, as PHPUnit tests can help to validate the issue and code changes and prevent future regressions.
Added an if statement with
isset()
to confirm that$angle_units[ $unit ]
is valid before assigning it to$factor
to avoid outputting a PHP warning.