[wp-trac] [WordPress Trac] #57469: Uncaught Error: array_merge(): Argument #3 must be of type array, null given in wp-includes/widgets.php on line 1342

WordPress Trac noreply at wordpress.org
Sun Jan 15 21:02:11 UTC 2023


#57469: Uncaught Error: array_merge(): Argument #3 must be of type array, null
given in wp-includes/widgets.php on line 1342
--------------------------+-----------------------------
 Reporter:  kesselb       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:  6.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When changing from PHP 7.4 to PHP 8.0 it's not possible to activate our
 theme.


 Fatal error: Uncaught Error: array_merge(): Argument #3 must be of type
 array, null given in wp-includes/widgets.php on line 1342


 {{{
 array_merge()
 wp-includes/widgets.php:1342

 retrieve_widgets()
 wp-includes/widgets.php:1287

 _wp_sidebars_changed()
 wp-includes/class-wp-hook.php:310

 WP_Hook::apply_filters()
 wp-includes/class-wp-hook.php:332

 WP_Hook::do_action()
 wp-includes/plugin.php:517

 do_action()
 wp-includes/theme.php:3395

 check_theme_switched()
 wp-includes/class-wp-hook.php:308

 WP_Hook::apply_filters()
 wp-includes/class-wp-hook.php:332

 WP_Hook::do_action()
 wp-includes/plugin.php:517

 do_action()
 wp-settings.php:617

 require_once()
 wp-config.php:103

 require_once()
 wp-load.php:50

 require_once()
 wp-admin/admin.php:34

 require_once()
 wp-admin/plugins.php:10
 }}}


 Line 1342:
 {{{#!php
 <?php

 $shown_widgets = array_merge( ...array_values( $sidebars_widgets ) );
 }}}


 $sidebars_widgets


 {{{
 array (
   'wp_inactive_widgets' =>
   array (
   ),
   'sidebar-standard' =>
   array (
   ),
   'sidebar-marken' => NULL,
   'sidebar-typen' => NULL,
   'sidebar-test' => NULL,
   'sidebar-zubehoer' => NULL,
   'sidebar-ratgeber' => NULL,
 )
 }}}


 PHP 8.0+ throws a type error when a non-array value is given to
 array_merge.

 I guess NULL is not a valid value for the sidebar widgets.
 Maybe our theme wrote this weird state to the options field.

 Patch: https://github.com/WordPress/wordpress-develop/pull/3848

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


More information about the wp-trac mailing list