WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 3 weeks ago

#46252 accepted enhancement

Enhance Error Message for Meta Fields

Reported by: apermo Owned by: TimothyBlynJacobs
Milestone: 5.3 Priority: normal
Severity: minor Version:
Component: REST API Keywords: needs-patch
Focuses: Cc:

Description

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L270

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L283

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L333

<?php
return new WP_Error(
   'rest_meta_database_error',
   __( 'Could not update meta value in database.' ),
   array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
);
?>

These 3 Error messages are actually not helpful, if you submit multiple meta fields, you don't know (at least not on the remote site) which meta was throwing the error.

It would be more helpful/self explaining if the error message was more like:

sprintf( __( 'Could not update the meta value "%s" in database.' ), $meta_key ), 

this way you could directly tell which meta field is throwing the error.

Change History (3)

#1 @pento
5 months ago

  • Version trunk deleted

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.


3 weeks ago

#3 @TimothyBlynJacobs
3 weeks ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.3
  • Owner set to TimothyBlynJacobs
  • Status changed from new to accepted

I agree this would be a quite helpful improvement.

Considering some of the other metadata improvements planned for 5.3, milestoning for 5.3 as well.

Note: See TracTickets for help on using tickets.