Editor: Avoid unnecessary array_merge in WP_Style_Engine::parse_block_styles().

This adds an `! empty()` check for classnames and declarations to avoid calling array_merge() with an empty value.

Props mukesh27, ramonopoly, aaronrobertshaw.
Fixes #62317.

Built from https://develop.svn.wordpress.org/trunk@59442


git-svn-id: http://core.svn.wordpress.org/trunk@58828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe McGill 2024-11-20 21:29:22 +00:00
parent 37c8e1ae21
commit 134e355f13
2 changed files with 10 additions and 3 deletions

View File

@ -454,8 +454,15 @@ final class WP_Style_Engine {
continue;
}
$parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], static::get_classnames( $style_value, $style_definition ) );
$parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], static::get_css_declarations( $style_value, $style_definition, $options ) );
$classnames = static::get_classnames( $style_value, $style_definition );
if ( ! empty( $classnames ) ) {
$parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], $classnames );
}
$css_declarations = static::get_css_declarations( $style_value, $style_definition, $options );
if ( ! empty( $css_declarations ) ) {
$parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], $css_declarations );
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59441';
$wp_version = '6.8-alpha-59442';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.