[wp-trac] [WordPress Trac] #38700: REST API: Cannot send an empty or no-op comment update

WordPress Trac noreply at wordpress.org
Tue Nov 29 00:04:42 UTC 2016


#38700: REST API: Cannot send an empty or no-op comment update
------------------------------------------------+--------------------------
 Reporter:  jnylen0                             |       Owner:  rmccue
     Type:  defect (bug)                        |      Status:  assigned
 Priority:  normal                              |   Milestone:  Future
Component:  REST API                            |  Release
 Severity:  normal                              |     Version:  trunk
 Keywords:  has-patch has-unit-tests 4.8-early  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------

Comment (by jnylen0):

 In [attachment:38700.6.diff]:

 - Comment updates that do not result in any rows updated are OK.  Add test
 for this situation.
 - Incidental bugfix: return a better error message for updating a comment
 with an invalid post ID.  Currently it's a generic 500.
 - Incidental bugfix: return a 500 if `$wpdb->update` fails.  Currently
 this is not detected or handled.

 The root cause of this ticket (HTTP 500 on a "no-op" comment update) is
 inconsistent return values from `wp_update_comment`: `0` can indicate
 either failure (error) or success (0 rows updated).

 We can fix it at the API level by handling
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/comment.php?rev=39349&marks=2145-2148,2150-2153#L2129 both error
 cases] that would cause `wp_update_comment` to return `0`.  One is
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-
 api/endpoints/class-wp-rest-comments-
 controller.php?rev=39349&marks=659-663#L647 already handled]; this patch
 adds better handling for the other one (invalid post ID).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38700#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list