diff --git a/features/cache.feature b/features/cache.feature index 472f28d1..941698de 100644 --- a/features/cache.feature +++ b/features/cache.feature @@ -132,3 +132,18 @@ Feature: Managed the WordPress object cache """ Error: Could not replace object 'bar' in group 'foo'. Does it not exist? """ + + Scenario: Flushing cache on a multisite installation + Given a WP multisite installation + + When I try `wp cache flush` + Then STDERR should not contain: + """ + Warning: Ignoring the --url= argument because flushing the cache affects all sites on a multisite installation. + """ + + When I try `wp cache flush --url=example.com` + Then STDERR should contain: + """ + Warning: Ignoring the --url= argument because flushing the cache affects all sites on a multisite installation. + """ diff --git a/src/Cache_Command.php b/src/Cache_Command.php index 1b5c8b17..fd2d0c57 100644 --- a/src/Cache_Command.php +++ b/src/Cache_Command.php @@ -155,8 +155,12 @@ public function delete( $args, $assoc_args ) { * Success: The cache was flushed. */ public function flush( $args, $assoc_args ) { - $value = wp_cache_flush(); + if ( WP_CLI::has_config( 'url' ) && ! empty( WP_CLI::get_config()['url'] ) && is_multisite() ) { + WP_CLI::warning( 'Ignoring the --url= argument because flushing the cache affects all sites on a multisite installation.' ); + } + + $value = wp_cache_flush(); if ( false === $value ) { WP_CLI::error( 'The object cache could not be flushed.' ); }