Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#46252 closed enhancement (fixed)

Enhance Error Message for Meta Fields

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

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.

Attachments (2)

46252.diff​ (1.6 KB ) - added by AkSDvP 7 years ago.
46252.2.diff​ (1.6 KB ) - added by AkSDvP 7 years ago.

Download all attachments as: .zip

Change History (9)

#1 @pento
8 years ago

  • Version trunk

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


7 years ago

#3 @TimothyBlynJacobs
7 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → 5.3
  • Owner set to TimothyBlynJacobs
  • Status new → 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.

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


7 years ago

#5 @AkSDvP
7 years ago

With reference to the above conversation, I have created a patch to change exception messages. Please find & review associated patch attached herewith.

#6 @AkSDvP
7 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#7 @SergeyBiryukov
7 years ago

  • Resolution → fixed
  • Status accepted → closed

In 45681:

REST API: Make "Could not update meta value in database" error messages more helpful.

Props apermo, AkSDvP.
Fixes #46252.

Note: See TracTickets for help on using tickets.