From 4db320d94ceac700b3d3a53e602d1d2a7ac159ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stephan=20Gro=C3=9Fberndt?= <stephan.grossberndt@typo3.org>
Date: Fri, 6 May 2022 10:48:35 +0200
Subject: [PATCH] [BUGFIX] Avoid postgresql error previewing a
 fe_group-protected page
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Avoid a postgresql error when previewing a page from the backend which
has an access protection by a fe_group due to PreviewSimulator faking
a fe_user with uid PHP_INT_MAX and sql failure to update the is_online
status of this fake user in PostgreSQL as column fe_users.uid is of type
integer and thus has max value of 2147483647 instead of PHP_INT_MAX.

Releases: main, 11.5, 10.4
Resolves: #97564
Change-Id: I16c866c368a9b3f5ac6bdfacf2c6660a7046df5a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74552
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
---
 .../Classes/Authentication/FrontendUserAuthentication.php     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
index b17fb2b7672a..7b330faabb62 100644
--- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
+++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
@@ -643,7 +643,9 @@ class FrontendUserAuthentication extends AbstractUserAuthentication
      */
     public function updateOnlineTimestamp()
     {
-        if (!is_array($this->user) || !$this->user['uid']
+        if (!is_array($this->user)
+            || !$this->user['uid']
+            || $this->user['uid'] === PHP_INT_MAX // Simulated preview user (flagged with PHP_INT_MAX uid)
             || $this->user['is_online'] >= $GLOBALS['EXEC_TIME'] - 60) {
             return;
         }
-- 
GitLab