Skip to content

Commit

Permalink
Fix content controller to check published before last modified (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
javihgil committed Jun 4, 2024
1 parent 349766f commit b702e2a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Controller/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ public function renderRoutePath(RoutePathInterface $routePath, Request $request)

$response = new Response();

/** @var ?ContentVersionInterface $publishedVersion */
$publishedVersion = $content->getPublishedVersion();

if (!$publishedVersion) {
throw $this->createNotFoundException();
}

if ($this->contentCacheLastModifiedEnabled) {
$response->setEtag(md5($content->getId().$content->getLastModified()?->getTimestamp().$this->contentVersionCompiler->getCompileKeyFromRequest($content->getPublishedVersion(), $request)));
$response->setEtag(md5($content->getId().$content->getLastModified()?->getTimestamp().$this->contentVersionCompiler->getCompileKeyFromRequest($publishedVersion, $request)));
$response->setLastModified($content->getLastModified());
// Set response as public. Otherwise it will be private by default.
$response->setPublic();
Expand All @@ -32,13 +39,6 @@ public function renderRoutePath(RoutePathInterface $routePath, Request $request)
}
}

/** @var ?ContentVersionInterface $publishedVersion */
$publishedVersion = $content->getPublishedVersion();

if (!$publishedVersion) {
throw $this->createNotFoundException();
}

$pageContent = $this->contentVersionManager->getCompiledContent($publishedVersion, $request);

// create response
Expand Down

0 comments on commit b702e2a

Please sign in to comment.