From 0850c2f3620445a7e0aa01610bafcd078bf60d63 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 25 Apr 2019 21:08:07 +0300 Subject: [PATCH 1/2] Added `Cache::clearCache('touch')` parameter for just forcing simple cache clear --- CHANGELOG.md | 1 + system/src/Grav/Common/Cache.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1c2c4af..c937b788e 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('touch')` parameter for just forcing simple cache clear 1. [](#bugfix) * Fixed `$grav['route']` from being modified when the route instance gets modified diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 314ab1184..394566701 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 'touch': + $remove_paths = []; + break; default: if (Grav::instance()['config']->get('system.cache.clear_images_by_default')) { $remove_paths = self::$standard_remove; From ec1fc1f1e30fad9bdc6b2f1776dab05ebacf6508 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 26 Apr 2019 09:54:14 +0300 Subject: [PATCH 2/2] Change cache touch parameter to invalidate, added CLI option for it --- CHANGELOG.md | 2 +- system/src/Grav/Common/Cache.php | 2 +- system/src/Grav/Console/Cli/ClearCacheCommand.php | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7443bec92..f3e72643e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 1. [](#new) * Added `Route::withoutParams()` methods * Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin - * Added `Cache::clearCache('touch')` parameter for just forcing simple cache clear + * 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 394566701..8b8317736 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -437,7 +437,7 @@ class Cache extends Getters case 'tmp-only': $remove_paths = self::$tmp_remove; break; - case 'touch': + case 'invalidate': $remove_paths = []; break; default: 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'; }