Make WordPress Core

Opened 3 years ago

Closed 5 months ago

#38469 closed defect (bug) (invalid)

wp-includes/widgets.php:1208 Undefined index: wp_inactive_widgets

Reported by: onnimonni Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Widgets Keywords: has-patch
Focuses: Cc:



Multiple persons can reproduce this error in our company.

After I switch themes I'll get notice about widgets.

It happens in wp-includes/widgets.php:1208

I'm using custom wp-content/install.php which doesn't add any widgets because we don't usually use them at all.

This problem gets fixed when I add this snippet in my mu-plugins:

add_action( 'init', function() {
    global $sidebars_widgets;
    if (!isset($sidebars_widgets['wp_inactive_widgets'])) {
        $sidebars_widgets['wp_inactive_widgets'] = [];

Custom install.php can be found here: https://github.com/devgeniem/better-wp-install-dropin/blob/master/install.php


$ wp core version

$ php -v
PHP 7.0.12-1

Change History (3)

#1 @onnimonni
3 years ago

This can also be fixed by adding following line to install.php:

update_option( 'sidebars_widgets', array( 'wp_inactive_widgets' => array() ) );

We should either document this behaviour into codex or core should have fix which handles this situation automatically.

#2 @desrosj
11 months ago

  • Component changed from General to Widgets
  • Keywords has-patch close 2nd-opinion added
  • Version changed from 4.6.1 to 2.8

Thanks for opening this, @onnimonni!

It looks like your custom install script is now correctly adding an empty array to the wp_inactive_widgets key for the sidebars_widgets option.

My initial thought is that this notice should not be fixed. This notice indicates that something has removed that index from the array (or has never set it) and is causing a problem. Also, this was only occurring because your custom installer was not initializing the wp_inactive_widgets index and not due to a bug in core.

Marking as a close candidate pending a second opinion.

#3 @desrosj
5 months ago

  • Keywords close 2nd-opinion removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Going to close this one out. This is not an issue in WordPress Core.

Note: See TracTickets for help on using tickets.