[wp-hackers] add_post_meta won't save unescaped data. Why?

Dion Hulse (dd32) wordpress at dd32.id.au
Tue Jan 25 22:13:09 UTC 2011

Unfortunately all the metadata API's expect slashed input data:  

I'm not sure why that was carried over into add_metadata() when it was  
implemented, Ideally it should've stayed in add_post_meta() and friends..

But there you have it, It's yet another "backwards compatible" feature :)

On Wed, 26 Jan 2011 05:03:42 +1100, Baki Goxhaj <banago at gmail.com> wrote:

> Hi Hackers,
> So, I was trying to insert some meta data to a post inserted by
> wp_insert_post. It would not save the metadata and I found this solution:
> http://wordpress.org/support/topic/bug-add_post_meta-update_post_meta
> Basically, the unenscaped data will be not saved.
> *Doesn't: *add_post_meta($post_id, 'json-data', $json_string);
> *Works: *add_post_meta($post_id, 'json-data',  
> $wpdb->escape($json_string));
> Lea and I have the following questions:* Is this a bug or a feature?
> *
> Kindly,
> Baki Goxhaj
> www.wplancer.com | www.banago.info | proverbhunter.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Dion Hulse / dd32
  e: contact at dd32.id.au
  Web: http://dd32.id.au/

More information about the wp-hackers mailing list