#58351 closed defect (bug) (duplicate)
PHP Fatal error: Uncaught TypeError: array_merge()
| Reported by: | lenasterg | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Widgets | Version: | |
| Severity: | normal | Keywords: | php80 needs-test-info |
| Cc: | Focuses: |
Description
Hi all.
I have a multisite installation WordPress 6.2, PHP 8.1.
In some subsites, that after switched themes I get the following PHP Fatal error
PHP Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /wp-includes/widgets.php:1342
This is caused when executing the line of code
$shown_widgets = array_merge( ...array_values( $sidebars_widgets ) );,
I guess that means that the $sidebars_widgets variable is either null or contains a null value instead of an array.
A fix for that is to add the following two lines
$sidebars_widgets = array_filter($sidebars_widgets); if ( empty( $sidebars_widgets ) ) { return array(); }
before the line :
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/widgets.php#L1342
Bests,
Lena
Change History (9)
#5
@
3 years ago
Hi @jrf.
I have no clue. It happened on in one subsite, which the user hadn't edited it for more than a year.
During this period, we updated the multisite installation from WP 4.9+ to 6.2.1.
The user can't remember the initial theme, his blog had.
This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.
3 years ago
#7
@
3 years ago
- Keywords needs-testing-info added
During test triage review of this ticket, it was agreed that needs-testing-info might help move it forward. Why? This issue may be challenging to reproduce and validate a patch. Also, in the process, additional research and context into what caused the issue might be revealed, as suggested in comment:4.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks @lenasterg for reporting this.
While your proposal fixes the immediate issue, it doesn't address the actual issue, which is "how did that
nullvalue get in the$sidebar_widgetsarray ?"I think this needs a little deeper investigation and backtracing to figure out what is really going on.