[wp-trac] [WordPress Trac] #25092: WP_Post->post_author is not INT

WordPress Trac noreply at wordpress.org
Sat Dec 28 04:36:48 UTC 2013


#25092: WP_Post->post_author is not INT
--------------------------+---------------------
 Reporter:  1994rstefan   |       Owner:  nacin
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  3.7
Component:  General       |     Version:  3.6
 Severity:  minor         |  Resolution:  fixed
 Keywords:  has-patch     |
--------------------------+---------------------

Old description:

> <font style='background-color: rgb(255, 255, 160) ! important;'><font
> style='background-color: rgb(255, 255, 160) ! important;'><font style
> ='background-color: rgb(255, 255, 160) !
> important;'>WP_Post</font></font></font>->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.

New description:

 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.

--

Comment (by SergeyBiryukov):

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

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25092#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list