summaryrefslogtreecommitdiffstats
path: root/wp-includes/rest-api/fields
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
commitfa9a33d818470a5796f0ff8797f98b510ed8de18 (patch)
treebde6a1eede376f9b5df5898ce812330152984d8e /wp-includes/rest-api/fields
parentReleasing progress-linux version 6.4.3+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.tar.xz
wordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.zip
Merging upstream version 6.5+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/rest-api/fields')
-rw-r--r--wp-includes/rest-api/fields/class-wp-rest-meta-fields.php19
1 files changed, 14 insertions, 5 deletions
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 60c3c3a..7b46905 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
@@ -141,6 +141,7 @@ abstract class WP_REST_Meta_Fields {
*/
public function update_value( $meta, $object_id ) {
$fields = $this->get_registered_fields();
+ $error = new WP_Error();
foreach ( $fields as $meta_key => $args ) {
$name = $args['name'];
@@ -163,35 +164,38 @@ abstract class WP_REST_Meta_Fields {
$current = get_metadata( $this->get_meta_type(), $object_id, $meta_key, true );
if ( is_wp_error( rest_validate_value_from_schema( $current, $args['schema'] ) ) ) {
- return new WP_Error(
+ $error->add(
'rest_invalid_stored_value',
/* translators: %s: Custom field key. */
sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ),
array( 'status' => 500 )
);
+ continue;
}
}
$result = $this->delete_meta_value( $object_id, $meta_key, $name );
if ( is_wp_error( $result ) ) {
- return $result;
+ $error->merge_from( $result );
}
continue;
}
if ( ! $args['single'] && is_array( $value ) && count( array_filter( $value, 'is_null' ) ) ) {
- return new WP_Error(
+ $error->add(
'rest_invalid_stored_value',
/* translators: %s: Custom field key. */
sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ),
array( 'status' => 500 )
);
+ continue;
}
$is_valid = rest_validate_value_from_schema( $value, $args['schema'], 'meta.' . $name );
if ( is_wp_error( $is_valid ) ) {
$is_valid->add_data( array( 'status' => 400 ) );
- return $is_valid;
+ $error->merge_from( $is_valid );
+ continue;
}
$value = rest_sanitize_value_from_schema( $value, $args['schema'] );
@@ -203,10 +207,15 @@ abstract class WP_REST_Meta_Fields {
}
if ( is_wp_error( $result ) ) {
- return $result;
+ $error->merge_from( $result );
+ continue;
}
}
+ if ( $error->has_errors() ) {
+ return $error;
+ }
+
return null;
}