diff --git a/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php b/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php index bccd0f01a4..40a48f87f9 100644 --- a/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php +++ b/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php @@ -24,7 +24,11 @@ public static function getLabel() { public function getContext() { $request = $this->requestStack->getCurrentRequest(); if ($request->hasSession()) { - return Crypt::hashBase64($request->getSession()->getId()); + $id = $request->getSession()->getId(); + if (!$id) { + throw new Exception('No session ID'); + } + return Crypt::hashBase64($id); } return 'none'; }