Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#46252 closed enhancement (fixed)

Enhance Error Message for Meta Fields

Reported by: apermo's profile apermo Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.3 Priority: normal
Severity: minor Version:
Component: REST API Keywords: has-patch needs-testing
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.

Attachments (2)

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

Download all attachments as: .zip

Change History (9)

#1 @pento
6 years ago

  • Version trunk deleted

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


5 years ago

#3 @TimothyBlynJacobs
5 years 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.

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


5 years ago

#5 @AkSDvP
5 years ago

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

@AkSDvP
5 years ago

@AkSDvP
5 years ago

#6 @AkSDvP
5 years ago

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

#7 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from accepted to 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.