[wp-trac] [WordPress Trac] #49609: Code simplification and bug prevention in get_the_content() (was: Minor code cleanup)

WordPress Trac noreply at wordpress.org
Wed Mar 11 15:08:38 UTC 2020


#49609: Code simplification and bug prevention in get_the_content()
-------------------------------+-----------------------
 Reporter:  dontdream          |       Owner:  (none)
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:
 Severity:  minor              |  Resolution:
 Keywords:  has-patch close    |     Focuses:
-------------------------------+-----------------------

Comment (by dontdream):

 Only two additional considerations:

 First, I realized that "code cleanup" isn't a good choice of words,
 because it might suggest that the code isn't "clean" right now. Obviously
 that  wasn't my intention, I should have said "code simplification" (my
 English is limited, sorry).

 Second, `get_the_content()` assumes that, when the `global $post` is set,
 `global $page, $more, $preview, $pages, $multipage` are also correctly
 set, but that's not always the case. At least `$pages` is sometimes not
 set up correctly, as shown by a report I received a few days ago, see:

 https://wordpress.org/support/topic/warning-count-parameter-must-be-an-
 array-or-an-object-that-implements-counta-10/

 I haven't been able to reproduce the problem, but if we replace
 `compact()` with `generate_postdata()`, we guarantee that `$elements` is
 set correctly even when the `$post` argument is null.

 To conclude, I think I've shared all the information I have and now I
 leave the final decision to you. In the meantime, I'm going to edit the
 ticket summary for clarity.

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


More information about the wp-trac mailing list