From d91b17523184b4c9913c6cc1d365a9b7cbd68c53 Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Fri, 23 Feb 2024 10:17:59 +0100 Subject: [PATCH] [BUGFIX] Prevent PHP deprecation in getCookieName() Resolves: #103182 Releases: main, 12.4 Change-Id: If16e37c638a07e3afbb59d665141cc2ade583f4d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83083 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Andreas Kienast <a.fernandez@scripting-base.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Andreas Kienast <a.fernandez@scripting-base.de> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> --- .../Authentication/BackendUserAuthentication.php | 14 ++++---------- .../Authentication/FrontendUserAuthentication.php | 11 +++-------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index 95888f948337..cf5bc3e208c1 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -1810,18 +1810,12 @@ class BackendUserAuthentication extends AbstractUserAuthentication } /** - * Getter for the cookie name - * - * @static - * @return string returns the configured cookie name + * Returns the configured cookie name */ - public static function getCookieName() + public static function getCookieName(): string { - $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']); - if (empty($configuredCookieName)) { - $configuredCookieName = 'be_typo_user'; - } - return $configuredCookieName; + $configuredCookieName = trim((string)($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName'] ?? '')); + return $configuredCookieName !== '' ? $configuredCookieName : 'be_typo_user'; } /** diff --git a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php index fb4714717ad5..32ff2af66c12 100644 --- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php +++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php @@ -163,16 +163,11 @@ class FrontendUserAuthentication extends AbstractUserAuthentication /** * Returns the configured cookie name - * - * @return string */ - public static function getCookieName() + public static function getCookieName(): string { - $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cookieName']); - if (empty($configuredCookieName)) { - $configuredCookieName = 'fe_typo_user'; - } - return $configuredCookieName; + $configuredCookieName = trim((string)($GLOBALS['TYPO3_CONF_VARS']['FE']['cookieName'] ?? '')); + return $configuredCookieName !== '' ? $configuredCookieName : 'fe_typo_user'; } /** -- GitLab