diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 8f0303b6434..81433f1cb78 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -19,6 +19,7 @@ - Fixed a bug where unique validation for element URIs, usernames, and user email address was not case-insensitive on PostgreSQL installs. - Fixed a bug where element queries’ `uri` params, and user queries’ `firstName`, `lastName`, `username`, and `email` params, were not case-insensitive on PostgreSQL installs. - Fixed a bug where the CLI setup wizard was allowing empty database names. +- Fixed a bug where it wasn’t possible to clear template caches if template caching was disabled by the `enableTemplateCaching` config setting. ([#3229](https://github.com/craftcms/cms/issues/3229)) ## 3.0.21 - 2018-08-21 diff --git a/src/services/TemplateCaches.php b/src/services/TemplateCaches.php index 0869bb5b53b..62f2a6826d8 100644 --- a/src/services/TemplateCaches.php +++ b/src/services/TemplateCaches.php @@ -391,7 +391,7 @@ public function deleteCacheById($cacheId): bool return false; } - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches) { return false; } @@ -424,7 +424,7 @@ public function deleteCacheById($cacheId): bool */ public function deleteCachesByElementType(string $elementType): bool { - if ($this->_deletedAllCaches || !empty($this->_deletedCachesByElementType[$elementType]) || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches || !empty($this->_deletedCachesByElementType[$elementType]) === false) { return false; } @@ -447,11 +447,7 @@ public function deleteCachesByElementType(string $elementType): bool */ public function deleteCachesByElement($elements): bool { - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { - return false; - } - - if (!$elements) { + if ($this->_deletedAllCaches || empty($elements)) { return false; } @@ -485,16 +481,16 @@ public function deleteCachesByElement($elements): bool */ public function deleteCachesByElementId($elementId, bool $deleteQueryCaches = true): bool { - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { - return false; - } - - if (!$elementId) { + if ($this->_deletedAllCaches || !$elementId) { return false; } // Check the query caches too? - if ($deleteQueryCaches && Craft::$app->getConfig()->getGeneral()->cacheElementQueries) { + if ( + $deleteQueryCaches && + $this->_isTemplateCachingEnabled() && + Craft::$app->getConfig()->getGeneral()->cacheElementQueries + ) { if ($this->_deleteCachesIndex === null) { Craft::$app->getResponse()->on(Response::EVENT_AFTER_PREPARE, [$this, 'handleResponse']); $this->_deleteCachesIndex = []; @@ -542,7 +538,7 @@ public function handleResponse() */ public function deleteCachesByElementQuery(ElementQuery $query): bool { - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches) { return false; } @@ -562,7 +558,7 @@ public function deleteCachesByElementQuery(ElementQuery $query): bool */ public function deleteCachesByKey($key): bool { - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches) { return false; } @@ -582,7 +578,7 @@ public function deleteCachesByKey($key): bool */ public function deleteExpiredCaches(): bool { - if ($this->_deletedAllCaches || $this->_deletedExpiredCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches || $this->_deletedExpiredCaches) { return false; } @@ -609,7 +605,7 @@ public function deleteExpiredCaches(): bool public function deleteExpiredCachesIfOverdue(): bool { // Ignore if we've already done this once during the request - if ($this->_deletedExpiredCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedExpiredCaches) { return false; } @@ -632,7 +628,7 @@ public function deleteExpiredCachesIfOverdue(): bool */ public function deleteAllCaches(): bool { - if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) { + if ($this->_deletedAllCaches) { return false; }