Skip to content

Commit 50d20fa

Browse files
Return a proper WP_Error object when failing to update a comment (#514)
1 parent 9dad075 commit 50d20fa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

features/comment.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ Feature: Manage WordPress comments
7070
"""
7171
And the return code should be 1
7272

73+
Scenario: Updating an invalid comment should return an error
74+
Given a WP install
75+
76+
When I try `wp comment update 22 --comment_author=Foo`
77+
Then the return code should be 1
78+
And STDERR should contain:
79+
"""
80+
Warning: Could not update comment.
81+
"""
82+
7383
Scenario: Get details about an existing comment
7484
When I run `wp comment get 1`
7585
Then STDOUT should be a table containing rows:

src/Comment_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function update( $args, $assoc_args ) {
118118
$assoc_args,
119119
function ( $params ) {
120120
if ( ! wp_update_comment( $params ) ) {
121-
return new WP_Error( 'Could not update comment.' );
121+
return new WP_Error( 'db_error', 'Could not update comment.' );
122122
}
123123

124124
return true;

0 commit comments

Comments
 (0)