diff --git a/CHANGELOG.md b/CHANGELOG.md index ff319d0b6..4191c9d0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 1. [](#new) * Added `Route::withoutParams()` methods * Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin + * Added `Cache::clearCache('invalidate')` parameter for just invalidating the cache without deleting any cached files 1. [](#bugfix) * Fixed `$grav['route']` from being modified when the route instance gets modified * Fixed Assets options array mixed with standalone priority [#2477](https://github.com/getgrav/grav/issues/2477) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 314ab1184..8b8317736 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -437,6 +437,9 @@ class Cache extends Getters case 'tmp-only': $remove_paths = self::$tmp_remove; break; + case 'invalidate': + $remove_paths = []; + break; default: if (Grav::instance()['config']->get('system.cache.clear_images_by_default')) { $remove_paths = self::$standard_remove; diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php index 0ab4128b9..8ef6f4ff6 100644 --- a/system/src/Grav/Console/Cli/ClearCacheCommand.php +++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php @@ -21,6 +21,7 @@ class ClearCacheCommand extends ConsoleCommand ->setName('cache') ->setAliases(['clearcache', 'cache-clear']) ->setDescription('Clears Grav cache') + ->addOption('invalidate', null, InputOption::VALUE_NONE, 'Invalidate cache, but do not remove any files') ->addOption('purge', null, InputOption::VALUE_NONE, 'If set purge old caches') ->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all including compiled, twig, doctrine caches') ->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*') @@ -64,6 +65,8 @@ class ClearCacheCommand extends ConsoleCommand $remove = 'cache-only'; } elseif ($this->input->getOption('tmp-only')) { $remove = 'tmp-only'; + } elseif ($this->input->getOption('invalidate')) { + $remove = 'invalidate'; } else { $remove = 'standard'; }