Make WordPress Core


Ignore:
Timestamp:
02/09/2026 05:08:13 PM (4 months ago)
Author:
jorgefilipecosta
Message:

Block Supports: Prevent fatal error in WP_Duotone when the duotone attribute is an array.

Adds type checks to get_slug_from_attribute(), is_preset(), and get_all_global_style_block_names() to handle cases where the duotone attribute is an array of custom colors instead of a preset reference string.
This prevents an error when preg_match() receives an array instead of a string.

Props jorgefilipecosta, westonruter, xavilc.
Fixes #64612.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/duotone.php

    r61008 r61603  
    9494            'css-var-spaces'                  => array( 'var(--wp--preset--duotone--    ', '' ),
    9595            'pipe-slug-spaces'                => array( 'var:preset|duotone|  ', '' ),
     96            'array-of-colors'                 => array( array( '#000000', '#ffffff' ), '' ),
     97            'empty-array'                     => array( array(), '' ),
    9698        );
    9799    }
     
    165167            'css-var-missing-end-parenthesis' => array( 'var(--wp--preset--duotone--blue-orange', false ),
    166168            'invalid'                         => array( 'not a valid attribute', false ),
     169            'array-of-colors'                 => array( array( '#000000', '#ffffff' ), false ),
     170            'empty-array'                     => array( array(), false ),
    167171        );
    168172    }
Note: See TracChangeset for help on using the changeset viewer.