Make WordPress Core


Ignore:
Timestamp:
09/30/2020 03:44:09 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r48834 r49076  
    12311231                        $settings = $settings->getArrayCopy();
    12321232                    }
     1233
     1234                    unset( $settings['_multiwidget'] );
    12331235
    12341236                    // Find the max widget number for this type.
Note: See TracChangeset for help on using the changeset viewer.