Make WordPress Core

Ticket #36660: 36660.2.diff

File 36660.2.diff, 1.6 KB (added by westonruter, 9 years ago)
  • src/wp-includes/class-wp-customize-widgets.php

    diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
    index 5b3e702..52d174f 100644
    final class WP_Customize_Widgets { 
    10641064         * @return array
    10651065         */
    10661066        public function preview_sidebars_widgets( $sidebars_widgets ) {
    1067                 $sidebars_widgets = get_option( 'sidebars_widgets' );
     1067                $sidebars_widgets = get_option( 'sidebars_widgets', array() );
    10681068
    10691069                unset( $sidebars_widgets['array_version'] );
    10701070                return $sidebars_widgets;
  • tests/phpunit/tests/customize/widgets.php

    diff --git tests/phpunit/tests/customize/widgets.php tests/phpunit/tests/customize/widgets.php
    index 721f804..c0836d3 100644
    class Tests_WP_Customize_Widgets extends WP_UnitTestCase { 
    9999        }
    100100
    101101        /**
     102         * Test registering sidebars without an extant sidebars_widgets option.
     103         *
     104         * @see WP_Customize_Widgets::customize_register()
     105         * @see WP_Customize_Widgets::preview_sidebars_widgets()
     106         * @ticket 36660
     107         */
     108        function test_customize_register_with_deleted_sidebars() {
     109                $sidebar_id = 'sidebar-1';
     110                delete_option( 'sidebars_widgets' );
     111                register_sidebar( array( 'id' => $sidebar_id ) );
     112                $this->manager->widgets->customize_register();
     113                $this->assertEquals( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() );
     114        }
     115
     116        /**
    102117         * Tests WP_Customize_Widgets::get_selective_refreshable_widgets().
    103118         *
    104119         * @see WP_Customize_Widgets::get_selective_refreshable_widgets()