Skip to content

Commit

Permalink
Bugfix: Include dimensionIdentifier in cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikdro committed Jan 14, 2021
1 parent fdad17c commit 250d76c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Classes/Controller/JavaScriptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class JavaScriptController extends RestController
*/
protected $cookieName;

public function initializeRenderJavaScriptAction() {

public function initializeRenderJavaScriptAction()
{
$this->response->setComponentParameter(SetHeaderComponent::class, 'Cache-Control', 'max-age=0, private, must-revalidate');
}

Expand All @@ -73,8 +73,9 @@ public function renderJavaScriptAction(array $dimensions = [])
);

$cookie = json_decode($this->request->getHttpRequest()->getCookieParams()[$this->cookieName], true);

$consents = isset($cookie['consents'][$dimensionIdentifier]) ? $cookie['consents'][$dimensionIdentifier] : $cookie['consents']['default'] ?? $cookie['consents'];
$cacheIdentifier = 'kd_gdpr_cc_' . sha1(json_encode($consents));
$cacheIdentifier = 'kd_gdpr_cc_' . sha1(json_encode($consents) . $dimensionIdentifier);

if ($this->cache->has($cacheIdentifier)) {
$this->redirect('downloadGeneratedJavaScript', null, null, ['hash' => $cacheIdentifier]);
Expand Down

0 comments on commit 250d76c

Please sign in to comment.