[wp-trac] [WordPress Trac] #57446: Theme Switch, retrieve_widgets() Leading to Fatal Error

WordPress Trac noreply at wordpress.org
Wed Jan 11 17:05:47 UTC 2023


#57446: Theme Switch, retrieve_widgets() Leading to Fatal Error
--------------------------+-----------------------------
 Reporter:  verygoode     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Working with a user that began encountering fatals when accessing widgets.

 During troubleshooting on a test site, they switched the theme which led
 to the following error.

 {{{
 Fatal error: Uncaught Error: Cannot unset string offsets in
 /wordpress/core/6.1.1/wp-includes/widgets.php:1324
 Stack trace:
 #0 /wordpress/core/6.1.1/wp-includes/widgets.php(1287):
 retrieve_widgets(true)
 #1 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(309):
 _wp_sidebars_changed('enfold-child')
 #2 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(331):
 WP_Hook->apply_filters(NULL, Array)
 #3 /wordpress/core/6.1.1/wp-includes/plugin.php(476):
 WP_Hook->do_action(Array)
 #4 /wordpress/core/6.1.1/wp-includes/theme.php(3380):
 do_action('after_switch_th...', 'enfold-child', Object(WP_Theme))
 #5 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(307):
 check_theme_switched('')
 #6 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(331):
 WP_Hook->apply_filters(NULL, Array)
 #7 /wordpress/core/6.1.1/wp-includes/plugin.php(476):
 WP_Hook->do_action(Array)
 #8 /wordpress/core/6.1.1/wp-settings.php(598): do_action('init')
 #9 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-
 cli/php/WP_CLI/Runner.php(1336): require('/wordpress/core...')
 #10 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-
 cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress()
 #11 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-
 cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
 #12 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-
 cli/php/bootstrap.php(78):
 WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
 #13 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(32):
 WP_CLI\bootstrap()
 #14 phar:///usr/local/bin/wp-cli/php/boot-phar.php(11):
 include('phar:///usr/loc...')
 #15 /usr/local/bin/wp-cli(4): include('phar:///usr/loc...')
 #16 {main}
   thrown in /wordpress/core/6.1.1/wp-includes/widgets.php on line 1324
 }}}


 After this error was triggered, and perhaps due to opcache, it has been
 difficult to interact with the site.

 Attempts to utilize WP-CLI, adjust theme related settings in the _options
 table, and removing theme files have not been successful in getting the
 site responsive again.


 Conditions on the site appear to have led to a string to be present when
 widgets.php's `retrieve_widgets()` attempts `unset(
 $sidebars_widgets['array_version'] );`

 * https://developer.wordpress.org/reference/functions/retrieve_widgets/
 *
 https://developer.wordpress.org/reference/functions/check_theme_switched/

 ---
 Tested on

 WordPress 6.0.3 & 6.1.1
 PHP version 7.4, 8.0, 8.1, 8.2

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


More information about the wp-trac mailing list