Opened 7 years ago
Closed 4 years 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: |
Description
Hey!
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:
<?php 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
Details:
$ wp core version
4.6.1
$ php -v
PHP 7.0.12-1
Change History (3)
#2
@
5 years 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.
This can also be fixed by adding following line to install.php:
We should either document this behaviour into codex or core should have fix which handles this situation automatically.