#25092 closed defect (bug) (fixed)
WP_Post->post_author is not INT
| Reported by: | 1994rstefan | Owned by: | nacin |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.7 |
| Component: | General | Version: | 3.6 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
Description (last modified by )
WP_Post->post_author should be a INT not a STRING.
If you have following Code
$post = get_post(123); if($post->post_author !== wp_get_current_user()->ID) echo 'Not your Post';
it will always fail (printing "Not your Post") because wp_get_current_user()->ID is (as I would expect) a INT but $post->post_author is a STRING.
The WordPress Codex and also the inline PHP Documentation says that post_author is a INT.
Attachments (1)
Change History (13)
#2
follow-up:
↓ 3
@
13 years ago
- Keywords needs-docs added
- Resolution duplicate
- Status closed → reopened
The WordPress Codex and also the inline PHP Documentation says that post_author is a INT.
Don't trust the map, trust the terrain. So please fix the codex and the comments here as it looks like an documentation issue.
From a programmers standpoint you also need to treat those database values as user-values and you need to sanitize them first anyway to have correct working and stable code.
#3
in reply to: ↑ 2
@
13 years ago
Replying to hakre:
The WordPress Codex and also the inline PHP Documentation says that post_author is a INT.
Don't trust the map, trust the terrain. So please fix the codex and the comments here as it looks like an documentation issue.
You're welcome to fix the Codex, hakre.
I did not notice the documentation report. WP_Post's phpdoc should be changed, yes.
#7
@
13 years ago
- Keywords has-patch added
- Resolution fixed
- Status closed → reopened
25092.diff fixes a (minor) typo that was introduced in [25086].
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Duplicate of #22324. The short of it: Not going to change for now.