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


git-svn-id: http://core.svn.wordpress.org/trunk@48838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-09-30 15:46:08 +00:00
parent 09570be924
commit 829fc28a93
2 changed files with 3 additions and 1 deletions

View File

@ -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 ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49075';
$wp_version = '5.6-alpha-49076';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.