Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#36660 closed defect (bug) (fixed)

WP_Customize_Widgets::preview_sidebars_widgets() can return false

Reported by: ocean90's profile ocean90 Owned by: ocean90's profile ocean90
Milestone: 4.5.3 Priority: normal
Severity: normal Version: 4.5
Component: Customize Keywords: has-patch commit fixed-major
Focuses: Cc:

Description

Seeing this PHP notice on dotorg:

​E_WARNING: /wp-includes/class-wp-customize-widgets.php:385 - array_merge(): Argument #3 is not an array
array_merge(): Argument #3 is not an array
Timestamp: Mon, 25 Apr 2016 08:52:29 +0000 (1461574349)
File: /wp-includes/class-wp-customize-widgets.php
Line: 385

This seems to be caused by [37166] where the sidebars_widgets callback was moved before the wp_get_sidebars_widgets() call.
WP_Customize_Widgets::preview_sidebars_widgets() is using get_option( 'sidebars_widgets' ) without defining a default value so it falls back to false in case the site has no widgets.

Attachments (2)

36660.patch (571 bytes) - added by ocean90 9 years ago.
36660.2.diff (1.6 KB) - added by westonruter 9 years ago.

Download all attachments as: .zip

Change History (10)

@ocean90
9 years ago

#1 @westonruter
9 years ago

Related: #27965 (Error in theme customizer if all widget areas are empty)

@westonruter
9 years ago

#2 @westonruter
9 years ago

  • Keywords commit added
  • Owner set to westonruter
  • Status changed from new to reviewing

Added unit test in 36660.2.diff to verify the fix. Without the patch, the unit test fails with:

1) Tests_WP_Customize_Widgets::test_customize_register_with_deleted_sidebars
array_merge(): Argument #3 is not an array

src/wp-includes/class-wp-customize-widgets.php:385
tests/phpunit/tests/customize/widgets.php:112

#3 @westonruter
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37352:

Customize: Handle filtering sidebars_widgets when the underlying option is non-existent.

Fixes warning related to a non-array argument for array_merge() in WP_Customize_Widgets::customize_register().

See [37166].
See #36389.
Fixes #36660.

#4 @westonruter
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Re-opening for 4.5.2 consideration.

#5 @westonruter
9 years ago

  • Owner westonruter deleted
  • Status changed from reopened to assigned

#6 @ocean90
9 years ago

  • Keywords fixed-major added

This ticket was mentioned in Slack in #core by adamsilverstein. View the logs.


9 years ago

#8 @ocean90
9 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from assigned to closed

In 37453:

Customize: Handle filtering sidebars_widgets when the underlying option is non-existent.

Fixes warning related to a non-array argument for array_merge() in WP_Customize_Widgets::customize_register().

Merge of [37352] to the 4.5 branch.

See [37166].
See #36389.
Fixes #36660.

Note: See TracTickets for help on using tickets.