Make WordPress Core

Changeset 42362


Ignore:
Timestamp:
12/04/2017 08:11:11 PM (7 years ago)
Author:
obenland
Message:

Widgets: Don't try mapping empty sidebars.

Fixes a bug where the mapping logic would try mapping empty sidebars, resulting in PHP warnings.

Props ionvv, chetan200891 for initial patch.
Fixes #42603.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r42343 r42362  
    13341334    if ( is_array( $old_sidebars_widgets ) ) {
    13351335
     1336        // Remove empty sidebars, no need to map those.
     1337        $old_sidebars_widgets = array_filter( $old_sidebars_widgets );
     1338
    13361339        // Only check sidebars that are empty or have not been mapped to yet.
    13371340        foreach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ) {
  • trunk/tests/phpunit/tests/widgets.php

    r42343 r42362  
    730730
    731731        wp_widgets_init();
    732         $this->register_sidebars( array( 'sidebar-1', 'sidebar-2', 'sidebar-3', 'wp_inactive_widgets' ) );
     732        $this->register_sidebars( array( 'sidebar-1', 'sidebar-2', 'sidebar-3', 'sidebar-4', 'wp_inactive_widgets' ) );
    733733
    734734        // Test restoring sidebars widgets when previously activated.
     
    740740                    'sidebar-2'          => array(),
    741741                    'sidebar-3'          => array( 'unregistered_widget-1', 'text-1', 'media_image-1' ),
     742                    'sidebar-4'          => null, // Should be converted to array.
    742743                    'orphaned_widgets_1' => array( 'media_video-2' ),
    743744                ),
Note: See TracChangeset for help on using the changeset viewer.