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
This commit is contained in:
Sergey Biryukov 2020-09-30 15:44:09 +00:00
parent 8e3636b0d6
commit 76516b0830
1 changed files with 2 additions and 0 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 ) {