[wp-trac] [WordPress Trac] #46314: JSON strings in postmeta issue

WordPress Trac noreply at wordpress.org
Fri Feb 22 12:23:03 UTC 2019


#46314: JSON strings in postmeta issue
-------------------------------+------------------------------
 Reporter:  Jonua              |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Database           |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by Jonua):

 Hi, sorry for the wrong function name. Yes I talk about
 update_post_meta().

 I build a plugin years ago https://de.wordpress.org/plugins/advanced-
 custom-fields-table-field/ which has more than 20.000 active users now.
 That plugin adds table editing functionality for the Advanced Custom
 Fields Plugin. The user editing UI of the table is pure JavaScript driven.
 To save the table data (a JavaScript object) to WordPress meta, I had to
 use an input text field. At first glance, it was logical to me, to encode
 and save the data JavaScript object as JSON string. Well, this was a bad
 decision resulting in trouble. This annoyance drew my attention to the
 general problem of update_post_meta() removing backslashes.

 I would at least suggest that in the documentation to update_post_meta ()
 should pointed out, if one reads foreign meta data and stores them again
 with update_post_meta, that wp_slash() must be applied beforehand, in
 order not to change the original data.

 Thanks,
 Johann

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46314#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list