[wp-trac] [WordPress Trac] #58351: PHP Fatal error: Uncaught TypeError: array_merge()

WordPress Trac noreply at wordpress.org
Thu May 18 09:53:04 UTC 2023


#58351: PHP Fatal error:  Uncaught TypeError: array_merge()
--------------------------+-----------------------------
 Reporter:  lenasterg     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hi all.
 I have a multisite installation WordPress 6.2, PHP 8.1.
 In some subsites, that after switched themes I get the following PHP Fatal
 error

 ''PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be
 of type array, null given in /wp-includes/widgets.php:1342''

 This is caused when executing the line of code
 $shown_widgets = array_merge( ...array_values( $sidebars_widgets ) );,
 I guess that means that the $sidebars_widgets variable is either null or
 contains a null value instead of an array.

 A fix for that is to add the following two lines
 {{{#!php
 $sidebars_widgets = array_filter($sidebars_widgets);
 if ( empty( $sidebars_widgets ) ) {
     return array();
 }
 }}}
 before the line :
 https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/widgets.php#L1342


 Bests,
 Lena

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58351>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list