[wp-trac] [WordPress Trac] #48264: Item type of 'integer' fails to save unchanged values with 'array' type in register_meta()
WordPress Trac
noreply at wordpress.org
Wed Oct 9 16:31:38 UTC 2019
#48264: Item type of 'integer' fails to save unchanged values with 'array' type in
register_meta()
--------------------------------------+--------------------------------
Reporter: augustuswm | Owner: TimothyBlynJacobs
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.3
Component: Options, Meta APIs | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: rest-api
--------------------------------------+--------------------------------
Changes (by TimothyBlynJacobs):
* status: new => assigned
* focuses: => rest-api
* component: General => Options, Meta APIs
* owner: (none) => TimothyBlynJacobs
* milestone: Awaiting Review => 5.3
* keywords: => has-patch has-unit-tests
Comment:
Thanks for reporting this @augustuswm!
The intention was to be storing the data in the DB as a serialized array
where the primitive types were respected. I mistakenly thought that
`wp_slash` only applied slashes to string values, but as you pointed out
it casts everything to strings.
I think the change here is to only apply slashing to the string values. If
I call `update_post_meta( $post_id, $meta_key, [ 1, 2, 3 ] );` directly, I
get back an array of ints. I think this should behave the same in the REST
API.
I've attached a patch that makes those changes. Could you verify the patch
fixes your issue @augustuswm?
CC: @kadamwhite
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48264#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list