[wp-trac] [WordPress Trac] #42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284

WordPress Trac noreply at wordpress.org
Sat Aug 3 21:23:37 UTC 2019


#42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284
-------------------------------------------------+-------------------------
 Reporter:  internetwerk                         |       Owner:
                                                 |  boonebgorges
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.2
Component:  Posts, Post Types                    |     Version:  4.5
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  dev-feedback has-patch 2nd-opinion   |     Focuses:
  php73 has-unit-tests                           |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:108 jcdev518]:
 > I know this has been marked as "completed" but I ran into a similar
 issue with PHP 7.2 this many months later.
 > Same error, but on line 310 of post-template.php after calling
 get_the_content() outside of the main loop. This is in a singular page
 template where $post is already global.

 Thanks! I've seen this mentioned on support forums as well, and created a
 follow-up ticket: #47824.
 >
 > Although it seemed redundant, I wrapped the call inside the loop:
 > {{{#!php
 > <?php
 > while ( have_posts() ):
 >   the_post();
 >
 >   get_the_content();
 >
 > endwhile;
 > }}}
 >
 > and it fixed the error, as it's no longer trying to count() a null value
 in {{{#!php
 > {{{#!php
 > $elements['pages'];
 > }}}

 Yes, that's the correct way to solve it for now.

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


More information about the wp-trac mailing list