Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 5 months ago

#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 SergeyBiryukov)

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)

25092.diff​ (346 bytes ) - added by jamescollins 13 years ago.

Download all attachments as: .zip

Change History (13)

#1 @nacin
13 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #22324. The short of it: Not going to change for now.

#2 follow-up: @hakre
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.

Version 0, edited 13 years ago by hakre (next)

#3 in reply to: ↑ 2 @nacin
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.

#4 @SergeyBiryukov
13 years ago

  • Milestone → Awaiting Review

#5 @nacin
13 years ago

  • Keywords needs-codex added; needs-docs removed
  • Milestone Awaiting Review → 3.7

#6 @nacin
13 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status reopened → closed

In 25086:

PHPDoc for WP_Post properties. fixes #25092.

@jamescollins
13 years ago

#7 @jamescollins
13 years ago

  • Keywords has-patch added
  • Resolution fixed
  • Status closed → reopened

25092.diff fixes a (minor) typo that was introduced in [25086].

#8 @SergeyBiryukov
13 years ago

  • Resolution → fixed
  • Status reopened → closed

In 25097:

Fix typo in phpdoc. props jamescollins. fixes #25092.

#9 @bcworkz
13 years ago

  • Keywords needs-codex removed

Codex revised 22 Aug 13 by Johnbillion

#11 @SergeyBiryukov
13 years ago

  • Description modified (diff)

Didn't mean to change the description, not sure what happened here.

#12 @westonruter
5 months ago

In 62437:

Privacy: Correct type of WP_User_Request::$user_id from int to string/numeric-string.

Also adds numeric-string as richer PHPStan type to WP_Post::$post_author and WP_Post::$comment_count.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12018.
Follow-up to r25086, r43011.

Props masteradhoc, desrosj, garrett-eclipse, johnbillion, westonruter, apermo, SergeyBiryukov, TZ-Media, andizer, javorszky.
See #22324, #25092, #43443, #43985, #64898.
Fixes #44723.

Note: See TracTickets for help on using tickets.