Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #57246


Ignore:
Timestamp:
12/02/2022 11:02:23 PM (23 months ago)
Author:
sabernhardt
Comment:

Hi and thanks for the report!

I have similar warnings when I add a Cover block with duotone in the Neve theme.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #57246

    • Property Keywords needs-patch added
    • Property Focuses css added
    • Property Component changed from General to Themes
    • Property Summary changed from Duotune filter svg assumes hex to Duotone SVG function does not check for CSS variable color format
  • Ticket #57246 – Description

    initial v2  
    1 The function 'wp_get_duotone_filter_svg' and/or 'wp_tinycolor_string_to_rgb' do not verify the format of the color code passed to it.   My theme uses a css variable "var(--nv-text-dark-bg)".   After getting '$color' from 'string_to_rbg', it assumes the color array has valid values.   Since the original color is not one of the expected formats, this generates the following warnings:
    2 
    3  PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 422PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 423PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 424PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 425
    4 
    5 Please change one or the other method to check for css variables before using values from $color array.
     1The function `wp_get_duotone_filter_svg` and/or `wp_tinycolor_string_to_rgb` do not verify the format of the color code passed to it.   My theme uses a CSS variable `var(--nv-text-dark-bg)`.   After getting `$color` from `string_to_rgb`, it assumes the color array has valid values.   Since the original color is not one of the expected formats, this generates the following warnings:
     2{{{
     3PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 422
     4PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 423
     5PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 424
     6PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 425
     7}}}
     8Please change one or the other method to check for CSS variables before using values from `$color` array.