[wp-trac] [WordPress Trac] #49895: PHP Warning: count(): Parameter must be an array or an object that implements Countable

WordPress Trac noreply at wordpress.org
Mon Apr 13 20:30:48 UTC 2020


#49895: PHP Warning:  count(): Parameter must be an array or an object that
implements Countable
-------------------------------+-----------------------
 Reporter:  jbx                |       Owner:  (none)
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  5.4
 Severity:  minor              |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+-----------------------
Changes (by jbx):

 * status:  closed => reopened
 * resolution:  duplicate =>


Comment:

 Replying to [comment:1 afragen]:
 > It seems that, in this case, in the function `get_the_contents()` the
 `global $pages`, which is defined as an array, is not returning an array
 into the function.
 >
 > The cause of this needs to be investigated. Is this reproducible on
 other sites for you running PHP 7.4.x? Personally, I'm not seeing this
 error.

 I don't know if it is reproducable yet. What I have noticed is that it
 might be related to the Events Manager plugin, because it seems to be
 occurring on events pages. But I checked their template php file, and they
 have the `have_posts()` check, so I can't figure what could be the issue.


 {{{#!php
 <?php
 <?php if ( have_posts() ) : ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class();
 ?>>
                                 <?php
                     $post = get_post();
                     $EM_Event = em_get_event($post->ID, 'post_id');
                 ?>

                              <?php the_content(); ?>

 }}}


 Inside the event manager template itself then there is a `global
 $EM_Event;`

 Still not sure why this would propagate inside the code of WordPress, it
 should be sufficiently self contained.

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


More information about the wp-trac mailing list