From a7a46a0975f05e45ddecfa49e823e4103088b445 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/+/83095 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.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 c1512caa39c5..f0c2868cfd68 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -2044,18 +2044,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 983e4626a58a..c03f45c572d8 100644 --- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php +++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php @@ -191,16 +191,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