File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -475,14 +475,12 @@ public function delete( $args, $assoc_args ) {
475475
476476 if ( ! $ result ) {
477477 $ response = [ 'error ' , "Failed deleting comment {$ comment_id }. " ];
478+ $ status = $ this ->success_or_failure ( $ response );
479+ // Keep status as 1 (error) if any deletion fails
478480 } else {
479481 $ verb = ( $ force || 'trash ' === $ comment_status ) ? 'Deleted ' : 'Trashed ' ;
480482 $ response = [ 'success ' , "{$ verb } comment {$ comment_id }. " ];
481- ++$ successfully_deleted ;
482- }
483-
484- $ status = $ this ->success_or_failure ( $ response );
485- if ( $ status ) {
483+ $ this ->success_or_failure ( $ response );
486484 ++$ successfully_deleted ;
487485 }
488486 }
@@ -491,18 +489,14 @@ public function delete( $args, $assoc_args ) {
491489 wp_defer_term_counting ( false );
492490 }
493491
494- if ( $ status ) {
492+ if ( 0 === $ status ) {
495493 WP_CLI ::success ( "Deleted {$ successfully_deleted } comments. " );
496494 } else {
497495 $ error_count = $ total - $ successfully_deleted ;
498496 WP_CLI ::error ( "Failed deleting {$ error_count } comments. " );
499497 }
500498
501- if ( $ status ) {
502- exit ( 0 );
503- } else {
504- exit ( 1 );
505- }
499+ exit ( $ status );
506500 }
507501
508502 private function call ( $ args , $ status , $ success , $ failure ) {
You can’t perform that action at this time.
0 commit comments