Commit 834cba427e for wordpress.org

commit 834cba427e9af8f83ecfd446fe69b07e5cd7bbd3
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date:   Mon Feb 9 17:09:43 2026 +0000

    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.
    Built from https://develop.svn.wordpress.org/trunk@61603


    git-svn-id: http://core.svn.wordpress.org/trunk@60914 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/class-wp-duotone.php b/wp-includes/class-wp-duotone.php
index 69b56e090c..8666f85a0f 100644
--- a/wp-includes/class-wp-duotone.php
+++ b/wp-includes/class-wp-duotone.php
@@ -546,10 +546,14 @@ class WP_Duotone {
 	 *
 	 * @since 6.3.0
 	 *
-	 * @param string $duotone_attr The duotone attribute from a block.
-	 * @return string The slug of the duotone preset or an empty string if no slug is found.
+	 * @param string|string[] $duotone_attr The duotone attribute from a block.
+	 * @return string The slug of the duotone preset or an empty string if no slug is found (including when an array was passed).
 	 */
 	private static function get_slug_from_attribute( $duotone_attr ) {
+		if ( ! is_string( $duotone_attr ) ) {
+			return '';
+		}
+
 		// Uses Branch Reset Groups `(?|…)` to return one capture group.
 		preg_match( '/(?|var:preset\|duotone\|(\S+)|var\(--wp--preset--duotone--(\S+)\))/', $duotone_attr, $matches );

@@ -566,9 +570,13 @@ class WP_Duotone {
 	 * @since 6.3.0
 	 *
 	 * @param string $duotone_attr The duotone attribute from a block.
-	 * @return bool True if the duotone preset present and valid.
+	 * @param string|string[] $duotone_attr The duotone attribute from a block.
 	 */
 	private static function is_preset( $duotone_attr ) {
+		if ( ! is_string( $duotone_attr ) ) {
+			return false;
+		}
+
 		$slug      = self::get_slug_from_attribute( $duotone_attr );
 		$filter_id = self::get_filter_id( $slug );

@@ -1050,6 +1058,11 @@ class WP_Duotone {
 				continue;
 			}
 			// If it has a duotone filter preset, save the block name and the preset slug.
+			// Only process if it's a string (preset reference), not an array (custom colors).
+			if ( ! is_string( $duotone_attr ) ) {
+				continue;
+			}
+
 			$slug = self::get_slug_from_attribute( $duotone_attr );

 			if ( $slug && $slug !== $duotone_attr ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index eb9cbec47b..62d0c04af7 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.0-alpha-61602';
+$wp_version = '7.0-alpha-61603';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.