Skip to content

Commit a015917

Browse files
authored
Merge pull request #294 from wp-cli/fix/plugin-update-status-on-trunk
Check for `WP_Error` on bulk updates
2 parents 87c9e33 + 737fc15 commit a015917

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,14 @@ protected function update_many( $args, $assoc_args ) {
433433

434434
// Let the user know the results.
435435
$num_to_update = count( $items_to_update );
436-
$num_updated = count( array_filter( $result ) );
436+
$num_updated = count(
437+
array_filter(
438+
$result,
439+
static function ( $result ) {
440+
return $result && ! is_wp_error( $result );
441+
}
442+
)
443+
);
437444

438445
if ( $num_to_update > 0 ) {
439446
if ( ! empty( $assoc_args['format'] ) && 'summary' === $assoc_args['format'] ) {
@@ -448,9 +455,9 @@ protected function update_many( $args, $assoc_args ) {
448455
'name' => $info['name'],
449456
'old_version' => $info['version'],
450457
'new_version' => $info['update_version'],
451-
'status' => null !== $result[ $info['update_id'] ] ? 'Updated' : 'Error',
458+
'status' => ( null !== $result[ $info['update_id'] ] && ! is_wp_error( $result[ $info['update_id'] ] ) ) ? 'Updated' : 'Error',
452459
];
453-
if ( null === $result[ $info['update_id'] ] ) {
460+
if ( null === $result[ $info['update_id'] ] || is_wp_error( $result[ $info['update_id'] ] ) ) {
454461
$errors++;
455462
}
456463
}

0 commit comments

Comments
 (0)