[wp-trac] [WordPress Trac] #43374: PHP 7.2 Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/theme.php on line 356
WordPress Trac
noreply at wordpress.org
Wed Feb 21 16:02:19 UTC 2018
#43374: PHP 7.2 Warning: count(): Parameter must be an array or an object that
implements Countable in /wp-includes/theme.php on line 356
-----------------------------+------------------------------
Reporter: burlingtonbytes | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 4.9.4
Severity: minor | Resolution: duplicate
Keywords: | Focuses:
-----------------------------+------------------------------
Changes (by burlingtonbytes):
* severity: normal => minor
Comment:
Hi @jrf,
Thank you for your insight on the proposed solution.
If `$wp_theme_directories` should always be an array, then this
conditional addresses the issue more comprehensively:
`if ( empty($wp_theme_directories) || ( is_array($wp_theme_directories) &&
count($wp_theme_directories) <= 1 ) ) {`
This way, we still return the default '/themes' if `$wp_theme_directories`
is null, zero, or other invalid `empty()` value, OR is a valid array with
1 or fewer items. `count()` is only executed if `is_array()` passes.
I looked into #42814 before submitting this, but believe this to be a
distinct issue because that ticket does not cover this specific use of
`count()` in `get_theme_roots()`. The warning is effectively the same but
in this case it is being generated in '''wp-includes/theme.php''' which is
not referenced at all in #42814.
I may be missing something but I do not believe #42814 addresses this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43374#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list