Skip to content

Commit

Permalink
Bugfix fix feuser retrieval in TYPO3 12
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbochmann committed Nov 8, 2023
1 parent 16f1bd3 commit cf23560
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Classes/Utility/TYPO3.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Sys25\RnBase\Utility;

use tx_rnbase;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/***************************************************************
* Copyright notice
Expand Down Expand Up @@ -274,6 +277,9 @@ public static function isExtMinVersion($_EXTKEY, $version)
*/
public static function getFEUser()
{
if (self::isTYPO121OrHigher()) {
return ($GLOBALS['TYPO3_REQUEST'] ?? ServerRequestFactory::fromGlobals())->getAttribute('frontend.user');
}
if (empty($GLOBALS['TSFE'])) {
return null;
}
Expand All @@ -288,6 +294,10 @@ public static function getFEUser()
*/
public static function getFEUserUID()
{
if (self::isTYPO121OrHigher()) {
return GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user')->get('id');
}

$feuser = self::getFEUser();

return is_object($feuser) && isset($feuser->user['uid']) ? $feuser->user['uid'] : false;
Expand Down

0 comments on commit cf23560

Please sign in to comment.