diff --git a/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php b/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php index 46c2d06250..54e0498132 100644 --- a/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php +++ b/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php @@ -295,19 +295,17 @@ abstract class WP_REST_Meta_Fields { ); } - $meta_key = wp_slash( $meta_key ); - $meta_value = wp_slash( $value ); - // Do the exact same check for a duplicate value as in update_metadata() to avoid update_metadata() returning false. $old_value = get_metadata( $meta_type, $object_id, $meta_key ); + $subtype = get_object_subtype( $meta_type, $object_id ); if ( 1 === count( $old_value ) ) { - if ( $old_value[0] === $meta_value ) { + if ( (string) sanitize_meta( $meta_key, $value, $meta_type, $subtype ) === $old_value[0] ) { return true; } } - if ( ! update_metadata( $meta_type, $object_id, $meta_key, $meta_value ) ) { + if ( ! update_metadata( $meta_type, $object_id, wp_slash( $meta_key ), wp_slash( $value ) ) ) { return new WP_Error( 'rest_meta_database_error', __( 'Could not update meta value in database.' ), diff --git a/wp-includes/version.php b/wp-includes/version.php index fb59d9f678..64543a0f3c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-43739'; +$wp_version = '5.0-alpha-43740'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.