[wp-trac] [WordPress Trac] #13463: post_meta doesn't like objects

WordPress Trac wp-trac at lists.automattic.com
Thu May 20 17:06:07 UTC 2010


#13463: post_meta doesn't like objects
--------------------------+-------------------------------------------------
 Reporter:  tychay        |       Owner:                              
     Type:  defect (bug)  |      Status:  new                         
 Priority:  normal        |   Milestone:  Unassigned                  
Component:  Post Types    |     Version:  3.0                         
 Severity:  normal        |    Keywords:  add_post_meta, get_post_meta
--------------------------+-------------------------------------------------
 make an object with data like this

 $data = (object)
 array('primary'=>'blah','data'=>array(1,38243,238,'foo'));[[BR]]
 add_post_meta($post_id, 'testmeta', $data);[[BR]]
 get_post_meta($post_id, 'testmeta');

 You get errors of the sort…
 [20-May-2010 16:50:14] PHP Catchable fatal error:  Object of class
 stdClass could not be converted to string in /home/wpdev/public_html/wp-
 includes/formatting.php on line 1229[[BR]]
 [20-May-2010 16:50:14] PHP Stack trace:[[BR]]
 …[[BR]]
 [20-May-2010 16:50:14] PHP   4. add_post_meta() [[BR]]
 [20-May-2010 16:50:14] PHP   5. add_metadata() /home/wpdev/public_html/wp-
 includes/post.php:1157 [[BR]]
 [20-May-2010 16:50:14] PHP   6. stripslashes_deep()
 /home/wpdev/public_html/wp-includes/meta.php:54 [[BR]]
 [20-May-2010 16:50:14] PHP   7. stripslashes() /home/wpdev/public_html/wp-
 includes/formatting.php:1229

 when deserializing, you get nothing. If you deserialize an array of
 objects, you'll get an array back where the first value is the serialize
 with all objects replaced with "Object" and subsequent values containing
 serialized strings of the rest of the content.

 (Note: I put this in Post Types because I don't know what component meta
 is attached to. Please reassign bug if wrong.)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13463>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list