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

WordPress Trac noreply at wordpress.org
Wed Mar 20 15:48:52 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                           |
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * owner:  (none) => boonebgorges
 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"44941" 44941]:
 {{{
 #!CommitTicketReference repository="" revision="44941"
 Posts: Avoid the use of globals in `get_the_content()` and related
 functions.

 This changeset introduces `$post` parameters to `get_the_content()` and
 `wp_trim_excerpt()`. When a `$post` object is passed to one of these
 functions,
 the functions will operate on the data from that object, rather than from
 the
 post globals (`$authordata`, `$page`, etc). This ensures that the
 functions work
 in a predictable manner when used outside of the regular post loop.

 The global-mismatch problem is surfaced in cases where `get_the_excerpt()`
 is
 called outside of the post loop, on posts that don't have a defined
 excerpt. In
 these cases, the post globals - used to generate a fallback excerpt - may
 refer
 to the incorrect object, resulting in PHP notices or other unpredictable
 behavior. See #36934 for a related issue.

 Props spacedmonkey, kraftbj, Shital Patel.
 Fixes #42814.
 }}}

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


More information about the wp-trac mailing list