Skip to content

Commit

Permalink
fix(site): fix issue with empty null cache id for error404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Sep 14, 2022
1 parent fb5eec5 commit 45914a2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,25 @@ public function renderResponse($response, array $data)
*/
public function render(array $data)
{
if (isset($data['id'])) {
$dataID = $data['id'];
} else {
$dataID = strings($data['title'] .
$data['description'] .
$data['content'] .
$data['template'])->hash()->toString();
}

if (registry()->get('plugins.site.settings.cache.enabled')) {
filesystem()->directory(FLEXTYPE_PATH_TMP . '/site/')->ensureExists(0755, true);

$cacheFileID = FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($data['id']) . '.html';
$cacheFileID = FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($dataID) . '.html';

if (filesystem()->file($cacheFileID)->exists()) {
$renderedTemplate = filesystem()->file(FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($data['id']) . '.html')->get();
$renderedTemplate = filesystem()->file(FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($dataID) . '.html')->get();
} else {
$renderedTemplate = $this->fetch($data);
filesystem()->file(FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($data['id']) . '.html')->put($renderedTemplate);
filesystem()->file(FLEXTYPE_PATH_TMP . '/site/' . $this->getCacheID($dataID) . '.html')->put($renderedTemplate);
}

} else {
Expand Down

0 comments on commit 45914a2

Please sign in to comment.