Skip to content

Commit

Permalink
Disable template caching for tokenized requests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 23, 2022
1 parent 09181ba commit 8e1018e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Release Notes for Craft CMS 3.x

## Unreleased
- Template caching is no longer enabled for tokenized requests. ([#12458](https://github.com/craftcms/cms/issues/12458))
- Fixed an error that could occur when processing template caches in a console request, if a globally-scoped template cache was processed before it.

## 3.7.62 - 2022-12-13
Expand Down
10 changes: 8 additions & 2 deletions src/services/TemplateCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,14 @@ private function _isTemplateCachingEnabled(bool $global): bool
if (!Craft::$app->getConfig()->getGeneral()->enableTemplateCaching) {
$this->_enabled = $this->_enabledGlobally = false;
} else {
$this->_enabled = !Craft::$app->getRequest()->getIsConsoleRequest();
$this->_enabledGlobally = true;
// Don't enable template caches for tokenized requests
$request = Craft::$app->getRequest();
if ($request->getHadToken()) {
$this->_enabled = $this->_enabledGlobally = false;
} else {
$this->_enabled = !$request->getIsConsoleRequest();
$this->_enabledGlobally = true;
}
}
}
return $global ? $this->_enabledGlobally : $this->_enabled;
Expand Down

0 comments on commit 8e1018e

Please sign in to comment.