Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions features/cache.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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=<url> argument because flushing the cache affects all sites on a multisite installation.
"""
6 changes: 5 additions & 1 deletion src/Cache_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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.' );
}
Expand Down