From 76516b08305326dfc5d60d5ccce7ad533709d451 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 30 Sep 2020 15:44:09 +0000 Subject: [PATCH] Code Modernization: Ignore the `_multiwidget` property when collecting widget numbers in `WP_Customize_Manager::import_theme_starter_content()`. PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison In particular, when calling `max()` on an array with numeric values and a non-numeric string, in PHP 8 the string is returned instead of a number. For `::import_theme_starter_content()`, this resulted in retrieving the `_multiwidget` property instead of the maximum widget number for a particular type. By explicitly ignoring the `_multiwidget` property, we make sure to retrieve the correct widget number value. Follow-up to [48960], [49043]. See #50913. git-svn-id: https://develop.svn.wordpress.org/trunk@49076 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-customize-manager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 79f2b3eab3..58905d6822 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -1231,6 +1231,8 @@ final class WP_Customize_Manager { $settings = $settings->getArrayCopy(); } + unset( $settings['_multiwidget'] ); + // Find the max widget number for this type. $widget_numbers = array_keys( $settings ); if ( count( $widget_numbers ) > 0 ) {