[wp-trac] [WordPress Trac] #57469: retrieve_widgets(): fatal error when a sidebar's widgets set to null (array is expected)
WordPress Trac
noreply at wordpress.org
Wed Feb 7 18:56:00 UTC 2024
#57469: retrieve_widgets(): fatal error when a sidebar's widgets set to null (array
is expected)
--------------------------+-----------------------
Reporter: kesselb | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone:
Component: Widgets | Version: 4.9
Severity: normal | Resolution:
Keywords: php80 close | Focuses:
--------------------------+-----------------------
Changes (by ikriv):
* status: closed => reopened
* resolution: invalid =>
Comment:
I was sitting on an old theme for a few years, and I hit this bug. I would
see a TypeError exception in array_merge() any time I open the 'widgets'
page, or after I have upgraded to a new theme.
The problem seems to be corrupted widgets information in the database. An
investigation showed that $sidebars_widgets array contains a NULL item
with key 'subsidiary'.
I.e. it looked like this:
{{{
(
[wp_inactive_widgets] => Array(...)
[primary] => Array(...)
[subsidiary] => NULL
)
}}}
Since $sitebars_widgets is a global variable, it is hard to tell who and
why was adding a NULL element. Anyway, the problem goes away if I add the
following to retrieve_widgets() in wp-incudes/widgets.php just before the
call to _wp_remove_unregistered_widgets():
{{{
// remove any NULL elements
$sidebars_widgets = array_filter($sidebars_widgets);
}}}
I suggest to reopen this bug and add this filter to the production
version: corrupted databases happen, and it's an easy precaution.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57469#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list