[wp-trac] [WordPress Trac] #21309: Introduce WP_Post class

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 21 02:52:53 UTC 2012


#21309: Introduce WP_Post class
----------------------------+------------------
 Reporter:  scribu          |       Owner:
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  3.5
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |
----------------------------+------------------

Comment (by mdawaffe):

 {{{get_post()}}} does not handle the case when no arguments are passed and
 {{{$GLOBALS['post']}}} is not a {{{WP_Post}}}.  I guarantee code exists
 that manually sets the global.

 To reproduce:
 {{{
 $post = $wpdb->get_row( "SELECT * FROM `$wpdb->posts` WHERE `ID` = 10047"
 );
 $post_id = 0;
 var_dump( get_post( $post_id ) );
 }}}

 > PHP Fatal error:  Call to undefined method stdClass::filter() in
 /Users/mdawaffe/Sites/wordpress/wp-includes/post.php on line 404

 Attached a possible solution in 21309-global.diff.  I'm not sure what the
 best thing to do here is.  Should the global be modified to be a WP_Post
 object?  What will that do to anyone depending on odd reference behavior?

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


More information about the wp-trac mailing list