Skip to content

Commit

Permalink
Fixed #3229
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 27, 2018
1 parent 48506ec commit 20116b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 14 additions & 18 deletions src/services/TemplateCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function deleteCacheById($cacheId): bool
return false;
}

if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) {
if ($this->_deletedAllCaches) {
return false;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -542,7 +538,7 @@ public function handleResponse()
*/
public function deleteCachesByElementQuery(ElementQuery $query): bool
{
if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) {
if ($this->_deletedAllCaches) {
return false;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -632,7 +628,7 @@ public function deleteExpiredCachesIfOverdue(): bool
*/
public function deleteAllCaches(): bool
{
if ($this->_deletedAllCaches || $this->_isTemplateCachingEnabled() === false) {
if ($this->_deletedAllCaches) {
return false;
}

Expand Down

0 comments on commit 20116b7

Please sign in to comment.