WordPress.org

Make WordPress Core

Changeset 42363


Ignore:
Timestamp:
12/04/17 20:16:43 (8 days 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.
See #42603.

Merges [42362] to the 4.9 branch.

Location:
branches/4.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/widgets.php

    r41942 r42363  
    12951295    if ( is_array( $old_sidebars_widgets ) ) { 
    12961296 
     1297        // Remove empty sidebars, no need to map those. 
     1298        $old_sidebars_widgets = array_filter( $old_sidebars_widgets ); 
     1299 
    12971300        // Only check sidebars that are empty or have not been mapped to yet. 
    12981301        foreach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ) { 
  • branches/4.9/tests/phpunit/tests/widgets.php

    r41673 r42363  
    710710 
    711711        wp_widgets_init(); 
    712         $this->register_sidebars( array( 'sidebar-1', 'sidebar-2', 'sidebar-3', 'wp_inactive_widgets' ) ); 
     712        $this->register_sidebars( array( 'sidebar-1', 'sidebar-2', 'sidebar-3', 'sidebar-4', 'wp_inactive_widgets' ) ); 
    713713 
    714714        // Test restoring sidebars widgets when previously activated. 
     
    719719                'sidebar-2' => array(), 
    720720                'sidebar-3' => array( 'unregistered_widget-1', 'text-1', 'media_image-1' ), 
     721                'sidebar-4' => null, // Should be converted to array. 
    721722                'orphaned_widgets_1' => array( 'media_video-2' ), 
    722723            ), 
Note: See TracChangeset for help on using the changeset viewer.