From 4266f83f9591e1783a2e562750ece6447cee30b8 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 11 Apr 2018 01:33:40 -0700 Subject: [PATCH] Fixed #2720 --- CHANGELOG-v3.md | 5 +++++ src/services/TemplateCaches.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 618eec53ad6..877e4c0dcf6 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -1,5 +1,10 @@ # Release Notes for Craft CMS 3.x +## Unreleased + +### Fixed +- Fixed a bug where the Clear Caches utility was not deleting template caches. ([#2720](https://github.com/craftcms/cms/issues/2720)) + ## 3.0.2 - 2018-04-10 ### Added diff --git a/src/services/TemplateCaches.php b/src/services/TemplateCaches.php index 429873795df..eb6c9dfe6c7 100644 --- a/src/services/TemplateCaches.php +++ b/src/services/TemplateCaches.php @@ -428,15 +428,15 @@ public function deleteCachesByElementType(string $elementType): bool return false; } - $this->_deletedCachesByElementType[$elementType] = true; - $cacheIds = (new Query()) ->select(['cacheId']) ->from([self::$_templateCacheQueriesTable]) ->where(['type' => $elementType]) ->column(); - return $this->deleteCacheById($cacheIds); + $success = $this->deleteCacheById($cacheIds); + $this->_deletedCachesByElementType[$elementType] = true; + return $success; } /** @@ -586,15 +586,15 @@ public function deleteExpiredCaches(): bool return false; } - $this->_deletedExpiredCaches = true; - $cacheIds = (new Query()) ->select(['id']) ->from([self::$_templateCachesTable]) ->where(['<=', 'expiryDate', Db::prepareDateForDb(new \DateTime())]) ->column(); - return $this->deleteCacheById($cacheIds); + $success = $this->deleteCacheById($cacheIds); + $this->_deletedExpiredCaches = true; + return $success; } /** @@ -634,14 +634,14 @@ public function deleteAllCaches(): bool return false; } - $this->_deletedAllCaches = true; - $cacheIds = (new Query()) ->select(['id']) ->from([self::$_templateCachesTable]) ->column(); - return $this->deleteCacheById($cacheIds); + $success = $this->deleteCacheById($cacheIds); + $this->_deletedAllCaches = true; + return $success; } // Private Methods