[wp-trac] [WordPress Trac] #42860: PHP 7.2 warning - Parameter must be an array or an object that implements Countable in /wp-includes/class-wp-query.php on line 3035

WordPress Trac noreply at wordpress.org
Mon Jan 15 21:41:19 UTC 2018


#42860: PHP 7.2 warning - Parameter must be an array or an object that implements
Countable in /wp-includes/class-wp-query.php on line 3035
-------------------------------+--------------------
 Reporter:  lisota             |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  4.9.2
Component:  Query              |     Version:  4.9.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+--------------------

Comment (by SergeyBiryukov):

 Replying to [comment:6 dd32]:
 > The correct fix here is probably to ensure that `$this->posts` is always
 set to an array, even when `$this->request` is emptied out.

 The [source:tags/4.9.1/src/wp-includes/class-wp-
 query.php?marks=3019,3020#L3008 comment in WP_Query::set_found_posts()]
 specifically allows for `$this->posts` to not be an array though:
 {{{
 // Bail if posts is an empty array. Continue if posts is an empty string,
 // null, or false to accommodate caching plugins that fill posts later.
 }}}
 I think we should just check if `is_array()` before calling `count()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42860#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list