Skip to content

Commit eac9da1

Browse files
petitphpswissspidy
andcommitted
explicitly call update methods for clearer code
Co-authored-by: Pascal Birchler <[email protected]>
1 parent f1905af commit eac9da1

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Cache_Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ function ( $key ) {
568568

569569
if ( $patched_value === $old_value ) {
570570
WP_CLI::success( "Value passed for cache key '$key' is unchanged." );
571-
} elseif ( wp_cache_set( $key, $patched_value, $group, $expiration ) ) {
572-
WP_CLI::success( "Updated cache key '$key'." );
573571
} else {
574-
WP_CLI::error( "Could not update cache key '$key'." );
572+
$success = wp_cache_set( $key, $patched_value, $group, $expiration );
573+
if ( $success ) {
574+
WP_CLI::success( "Updated cache key '$key'." );
575+
} else {
576+
WP_CLI::error( "Could not update cache key '$key'." );
577+
}
575578
}
576579
}
577580
}

src/Transient_Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,13 @@ function ( $key ) {
560560

561561
if ( $patched_value === $old_value ) {
562562
WP_CLI::success( "Value passed for transient '$key' is unchanged." );
563-
} elseif ( $write_func( $key, $patched_value, $expiration ) ) {
564-
WP_CLI::success( "Updated transient '$key'." );
565563
} else {
566-
WP_CLI::error( "Could not update transient '$key'." );
564+
$success = $write_func( $key, $patched_value, $expiration );
565+
if ( $success ) {
566+
WP_CLI::success( "Updated transient '$key'." );
567+
} else {
568+
WP_CLI::error( "Could not update transient '$key'." );
569+
}
567570
}
568571
}
569572

0 commit comments

Comments
 (0)