Skip to content

Commit b2c8d8d

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59442 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4a03ebe commit b2c8d8d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/wp-includes/style-engine/class-wp-style-engine.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,15 @@ public static function parse_block_styles( $block_styles, $options ) {
454454
continue;
455455
}
456456

457-
$parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], static::get_classnames( $style_value, $style_definition ) );
458-
$parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], static::get_css_declarations( $style_value, $style_definition, $options ) );
457+
$classnames = static::get_classnames( $style_value, $style_definition );
458+
if ( ! empty( $classnames ) ) {
459+
$parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], $classnames );
460+
}
461+
462+
$css_declarations = static::get_css_declarations( $style_value, $style_definition, $options );
463+
if ( ! empty( $css_declarations ) ) {
464+
$parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], $css_declarations );
465+
}
459466
}
460467
}
461468

0 commit comments

Comments
 (0)