Commit 134e355f13 for wordpress.org
commit 134e355f13c4fb53d4dc0f16be267fd0812060e2
Author: Joe McGill <joemcgill@gmail.com>
Date: Wed Nov 20 21:29:22 2024 +0000
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
diff --git a/wp-includes/style-engine/class-wp-style-engine.php b/wp-includes/style-engine/class-wp-style-engine.php
index 5582aacbb1..1234efdc64 100644
--- a/wp-includes/style-engine/class-wp-style-engine.php
+++ b/wp-includes/style-engine/class-wp-style-engine.php
@@ -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 );
+ }
}
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index ab7c1bc1e3..f2c8eb091d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -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.