[wp-trac] [WordPress Trac] #51697: [PHP8] Uncaught TypeError: array_flip():
WordPress Trac
noreply at wordpress.org
Tue Nov 3 01:13:52 UTC 2020
#51697: [PHP8] Uncaught TypeError: array_flip():
----------------------------+---------------------
Reporter: bph | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.6
Component: Administration | Version: trunk
Severity: normal | Resolution:
Keywords: php8 | Focuses:
----------------------------+---------------------
Comment (by jrf):
Hi @bph, thanks for reporting this!
This is not necessarily an issue with WP Core, but more likely an issue
with a plugin or theme ''doing it wrong''.
`$menu_order` is an array and get pulled through the `menu_order` filter
just before the `array_flip()`, so one of the functions filtering the
variable will have broken things by either not returning anything or by
returning `null`.
Now, it is tempting to add an `(array)` cast to fix this or to wrap the
rest of the body of the condition in an `if ( is_array( $menu_order ) )
{}`, but that would only serve to hide the problem, not actually fix it.
This is a typical example of a filter which would really benefit from a
type safe variant of `apply_filters()` as proposed in #51525.
For now, @bph, I'd like to ask you gather some more information either by
using the [https://wordpress.org/plugins/query-monitor/ Query Monitor] or
by using the [https://wordpress.org/plugins/debug-bar-actions-and-filters-
addon/ Debug Bar Actions & Filter addon].
To figure out which plugin/theme/Core is causing the issue, we need to
know what functions are hooked into the `menu_order` filter and where they
are coming from (plugin/theme/Core) and if plugin/theme, preferably
including information on which version of the plugin/theme you are using.
Once that information is available, all functions listed will need to be
examined to figure out the culprit.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51697#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list