Skip to content

Commit df3a0b7

Browse files
authored
#158 Fix error for cached endpoints on preview
Fix a server error occurring when cache was enabled and the element was being previewed
1 parent b0649ab commit df3a0b7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/controllers/DefaultController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ public function actionIndex(string $pattern): Response
8989
$this->response->getHeaders()->setDefault('X-Robots-Tag', 'none');
9090

9191
// Before anything else, check the cache
92-
if (!($this->request->getIsPreview() || $this->request->getIsLivePreview())) {
93-
$cache = ArrayHelper::remove($config, 'cache', true);
94-
} else {
92+
$cache = ArrayHelper::remove($config, 'cache', true);
93+
if ($this->request->getIsPreview() || $this->request->getIsLivePreview()) {
94+
// Ignore config & disable cache for live preview
9595
$cache = false;
9696
}
97-
97+
9898
$cacheKey = ArrayHelper::remove($config, 'cacheKey')
9999
?? implode(':', [
100100
'elementapi',

0 commit comments

Comments
 (0)