Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Clear page cache for currently selected site in admin
givanz708a4c3c824d
diff --git a/admin/controller/tools/cache.php b/admin/controller/tools/cache.phpindex 0974d70..ee445df 100755--- a/admin/controller/tools/cache.php+++ b/admin/controller/tools/cache.php@@ -28,7 +28,7 @@ use Vvveb\System\CacheManager;class Cache extends Base {private function clear($fn) {- if (CacheManager :: $fn()) {+ if ($fn()) {$this->view->success[] = __('Cache deleted!');} else {$this->view->errors[] = __('Error purging cache!');@@ -38,31 +38,31 @@ class Cache extends Base {}function delete() {- return $this->clear('delete');+ return $this->clear(fn () => CacheManager :: delete());}function template() {- return $this->clear('clearCompiledFiles');+ return $this->clear(fn () => CacheManager :: clearCompiledFiles());}function page() {- return $this->clear('clearPageCache');+ return $this->clear(fn () => CacheManager :: clearPageCache($this->global['site_url']));}function database() {- return $this->clear('clearObjectCache');+ return $this->clear(fn () => CacheManager :: clearObjectCache());}function asset() {- return $this->clear('clearFrontend');+ return $this->clear(fn () => CacheManager :: clearFrontend());}function model() {- return $this->clear('clearModelCache');+ return $this->clear(fn () => CacheManager :: clearModelCache());}function image() {- return $this->clear('clearImageCache');+ return $this->clear(fn () => CacheManager :: clearImageCache());}function stale() {@@ -78,10 +78,16 @@ class Cache extends Base {'/storage/compiled_templates' => DIR_COMPILED_TEMPLATES,];+ $unwritable = [];+foreach ($folders as $folder => $path) {if (! is_writable($path)) {- $this->view->info[] = sprintf('Folder is not writable, clear cache might not work for this layer, make sure that <b>%s</b> is writable by php', $folder);+ $unwritable[] = $folder;}}++ if ($unwritable) {+ $this->view->info[] = sprintf('Folders <b>%s</b> are not writable, clear cache might not work for these layers', implode(', ', $unwritable));+ }}}diff --git a/system/cache-manager.php b/system/cache-manager.phpindex 44f5f46..0a4af30 100755--- a/system/cache-manager.php+++ b/system/cache-manager.php@@ -104,8 +104,8 @@ class CacheManager {return $cacheDriver->delete($namespace, $key);}- public static function clearPageCache($namespace = '') {- $pageCache = PageCache::getInstance();+ public static function clearPageCache($host = null, $namespace = '') {+ $pageCache = new PageCache($host);return $pageCache->purge($namespace);}diff --git a/system/page-cache.php b/system/page-cache.phpindex b6646f9..a876b29 100755--- a/system/page-cache.php+++ b/system/page-cache.php@@ -54,14 +54,17 @@ class PageCache {return self :: $instance;}- function __construct() {- $this->cacheFolder = $this->cacheFolder();+ function __construct($host = null) {+ $this->cacheFolder = $this->cacheFolder($host);$this->fileName = $this->fileName();//$this->canSaveCache = $this->canSaveCache();}- function cacheFolder() {- return DIR_PUBLIC . self :: CACHE_DIR . ($_SERVER['HTTP_HOST'] ?? 'default');+ function cacheFolder($host) {+ $host = $host ?? $_SERVER['HTTP_HOST'] ?? '';+ $hostWp = substr($host, 0, strpos($host, ':') ?: null);++ return DIR_PUBLIC . self :: CACHE_DIR . ($hostWp ?? 'default');}function fileName() {@@ -263,7 +266,7 @@ class PageCache {if (! @rmdir($file)) {clearstatcache(false, $file);}- */+ */}}}