Support » Requests and Feedback » Bug? add_post_meta / update_post_meta
6 years, 4 months ago
I have a JSON encoded string $json_string which needs to be stored into the post meta data.
Doing the following damages the JSON encoded data:
add_post_meta($post_id, 'json-data', $json_string);
After searching the Internet I found that somebody else had a similar issue, and it looks as though the following addresses the issue:
add_post_meta($post_id, 'json-data', $wpdb->escape($json_string));
#1) Is this a fault with WordPress?
#2) Is the above safe? Is it likely to damage my clients data?
#3) Could there be a security risk with the default “add_post_meta” functionality?
6 years, 2 months ago
Thanks for sharing this – I was having the same trouble. I will drop a line to wp-hacker’s list and bring back what they say.