Skip to content

Commit 598c559

Browse files
Copilotswissspidy
andcommitted
Fix error message display and simplify return value check
Co-authored-by: swissspidy <[email protected]>
1 parent 98d8590 commit 598c559

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Post_Revision_Command.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function restore( $args ) {
7070
// Restore the revision
7171
$restored_post_id = wp_restore_post_revision( $revision_id );
7272

73-
if ( false === $restored_post_id || null === $restored_post_id ) {
73+
if ( false === $restored_post_id ) {
7474
WP_CLI::error( "Failed to restore revision {$revision_id}." );
7575
}
7676

@@ -147,7 +147,8 @@ public function diff( $args, $assoc_args ) {
147147
WP_CLI::error( "Field '{$field}' not found on revision {$from_id}." );
148148
}
149149
if ( ! isset( $to_revision->{$field} ) ) {
150-
WP_CLI::error( "Field '{$field}' not found on revision/post {$to_id}." );
150+
$to_error_id = $to_id ?? $to_revision->ID;
151+
WP_CLI::error( "Field '{$field}' not found on revision/post {$to_error_id}." );
151152
}
152153

153154
$left_string = $from_revision->{$field};

0 commit comments

Comments
 (0)