#59496 closed defect (bug) (fixed)
Duotone undefined index/array key warning
Reported by: | jacobcassidy | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.3 |
Component: | Editor | Keywords: | has-patch has-testing-info has-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 (7)
This ticket was mentioned in PR #5351 on WordPress/wordpress-develop by jacobcassidy.
12 months ago
#1
#2
@
11 months 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.
This ticket was mentioned in PR #6083 on WordPress/wordpress-develop by @Rahmohn.
7 months ago
#3
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/59496
#4
@
7 months ago
Hello @jacobcassidy and @hellofromTonya,
I did a small refactoring in the code change suggested by @jacobcassidy. Also, I added a unit test.
#5
@
7 months ago
- Owner set to swissspidy
- Resolution set to fixed
- Status changed from new to closed
In 57652:
@swissspidy commented on PR #5351:
7 months ago
#6
Committed in https://core.trac.wordpress.org/changeset/57652
@swissspidy commented on PR #6083:
7 months ago
#7
Committed in https://core.trac.wordpress.org/changeset/57652
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.