Index: core/modules/user/src/PrivateTempStore.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/modules/user/src/PrivateTempStore.php	(date 1510581385000)
+++ core/modules/user/src/PrivateTempStore.php	(revision )
@@ -207,7 +207,19 @@
    *   The owner.
    */
   protected function getOwner() {
-    return $this->currentUser->id() ?: $this->requestStack->getCurrentRequest()->getSession()->getId();
+    if ($currentUserId = $this->currentUser->id()) {
+      return $currentUserId;
+    }
+    // Otherwise, get the user ID from the session.
+    // Avoid NULL on chaining methods.
+    // Please consider using the Optional class or the Null Object pattern.
+    if ($this->requestStack->getCurrentRequest() === NULL) {
+      return '';
+    }
+    if ($this->requestStack->getCurrentRequest()->getSession() === NULL) {
+      return '';
+    }
+    return $this->requestStack->getCurrentRequest()->getSession()->getId();
   }
 
 }
