Skip to content

Commit

Permalink
2.8.2 - fix craftcms#153
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Sep 3, 2021
1 parent 0cb1f43 commit fb92fef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for Element API

## 2.8.2 - 2021-09-03

### Fixed
- Fixed a bug where custom `cache` durations were getting ignored. ([#153](https://github.com/craftcms/element-api/issues/153))

## 2.8.1 - 2021-09-01

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "craftcms/element-api",
"description": "Create a JSON API for your elements in Craft",
"version": "2.8.1",
"version": "2.8.2",
"type": "craft-plugin",
"keywords": [
"api",
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ public function actionIndex(string $pattern): Response
$this->response->getHeaders()->setDefault('X-Robots-Tag', 'none');

// Before anything else, check the cache
$cache = (
ArrayHelper::remove($config, 'cache', true) &&
!($this->request->getIsPreview() || $this->request->getIsLivePreview())
);
if (!($this->request->getIsPreview() || $this->request->getIsLivePreview())) {
$cache = ArrayHelper::remove($config, 'cache', true);
} else {
$cache = false;
}

$cacheKey = ArrayHelper::remove($config, 'cacheKey')
?? implode(':', [
Expand Down

0 comments on commit fb92fef

Please sign in to comment.