Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#27965 closed defect (bug) (worksforme)

Error in theme customizer if all widget areas are empty

Reported by: jramonredondo's profile jramon.redondo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Customize Keywords:
Focuses: Cc:


If all widget areas in a theme are empty (without any widget) then theme customizer fails with error:

PHP Warning: array_merge(): Argument #3 is not an array in class-wp-customize-widgets.php on line 403
PHP Warning: Invalid argument supplied for foreach() in class-wp-customize-widgets.php on line 436
PHP Fatal error: Cannot unset string offsets in class-wp-customize-widgets.php on line 990

If there is a widget in some area, all runs fine.

Change History (6)

#1 @jramon.redondo
10 years ago

  • Severity changed from normal to major

#2 @needle
10 years ago

Hi jramon.redondo, an interim fix can be found here: ticket:14876#comment:8 though it looks like the devs are not yet persuaded that sanity checking the return value is necessary. Hopefully your report will help tip the balance.

#3 @jramon.redondo
10 years ago

Needle, thanks a lot, your fix works like a charm. I am going to reproduce your fix here to help other people:

add_filter('sidebars_widgets', 'fix_error_in_theme_customizer_wp39', 999);

function fix_error_in_theme_customizer_wp39( $array ) {
	if ( !is_array( $array ) ) {
		$array = array();
	return $array;

#4 @jramon.redondo
10 years ago

As an additional information. I have tested that if a widget is added to some widget area an then it is removed, then bug is not fired even though all widget areas are empty again.

#5 @iseulde
10 years ago

  • Component changed from General to Customize

#6 @ocean90
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Severity changed from major to normal
  • Status changed from new to closed

Closing as worksforme. The return value from wp_get_sidebars_widgets() should be always an array.

Note: See TracTickets for help on using tickets.