Opened 9 years ago
Closed 9 years ago
#37173 closed defect (bug) (fixed)
get_the_content() has undocumented globals
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 0.71 |
Component: | Posts, Post Types | Keywords: | good-first-bug has-patch commit |
Focuses: | docs | Cc: |
Description
get_the_content()
is using several globals that are mentioned, but not explained in the docblock:
* @global int $page * @global int $more * @global bool $preview * @global array $pages * @global int $multipage
It took me a while before I was able to understand what they are and where/when they are set.
Attachments (3)
Change History (15)
#3
@
9 years ago
- Keywords needs-patch removed
I have tested this and used https://codex.wordpress.org/Global_Variables as reference. First time commiter, so I hope it will be good to go :)
#4
@
9 years ago
- Keywords has-patch added
- Owner set to goranseric
- Status changed from new to assigned
- Type changed from enhancement to defect (bug)
- Version changed from trunk to 0.71
@goranseric Thanks for the patch, I'll take a look and let you know if any changes are needed.
Assigning the ticket to mark the good-first-bug as "claimed".
#5
@
9 years ago
@goranseric In the case of descriptions for globals, we should be describing what the global represents at the initial point of access, rather than trying to be specific about what purpose they serve in the current context.
So for $multipage
, for instance, it's truly an indicator for whether pagination is play. It's technically an integer, but treated as a boolean.
So a possible description for $multipage
might be something like:
* @global int $multipage Boolean indicator for whether multiple pages are in play.
In the case of $pages
, what it really represents is an array of all pages. And so on with the others.
#6
@
9 years ago
@DrewAPicture thanks for pointing this out to me, and thanks for the example.
I have attached new descriptions according to your comments and also made comments more consistent to others in core.
Nice to see that we have a little freedom in expressing , I went quite stuffy :-D
This ticket was mentioned in Slack in #docs by morganestes. View the logs.
9 years ago
#10
@
9 years ago
Would it also be possible to mention at what point these globals are set? Currently, as a developer, it is really hard to debug get_the_content()
because it is so hard to understand where these values are coming from.
Same goes for
setup_postdata()
andWP_Query:: setup_postdata()
.