[wp-trac] [WordPress Trac] #42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284
WordPress Trac
noreply at wordpress.org
Wed Apr 18 13:38:19 UTC 2018
#42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284
-------------------------------+-----------------------
Reporter: internetwerk | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 4.9.6
Component: Posts, Post Types | Version: 4.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------------+-----------------------
Comment (by davisshaver):
If `get_the_content()` should not be called outside the loop, could we
patch by adding a conditional check to the top? The function would operate
as-is but would no longer throw a PHP warning.
{{{#!php
<?php
if ( ! in_the_loop() ) {
return '';
}
}}}
This is similar to how `get_post()` behaves.
{{{#!php
<?php
$post = get_post( $post );
if ( empty( $post ) ) {
return '';
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42814#comment:48>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list