From 2f6fbdb29f8ebf6e6c4461e431da3a7b723b1543 Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Thu, 10 Sep 2026 11:30:44 +0200 Subject: [PATCH] fix: replace deprecated getIndpEnv() in UserIntegration GeneralUtility::getIndpEnv() is deprecated since TYPO3 v14.3 and will be removed in v15.0. Because the event processor runs whenever an event is captured, the notice is emitted on ordinary requests, and with display_errors on it is printed before the payload - which corrupts backend AJAX responses. Read the remote address from the request's normalizedParams instead and skip it when there is no request, which also keeps the CLI path quiet. NormalizedParams has existed since TYPO3 9.2, so no supported version is affected. Fixes #125 --- Classes/Integration/UserIntegration.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Classes/Integration/UserIntegration.php b/Classes/Integration/UserIntegration.php index dc51d8f..6b3c846 100644 --- a/Classes/Integration/UserIntegration.php +++ b/Classes/Integration/UserIntegration.php @@ -12,6 +12,7 @@ use Sentry\UserDataBag; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\UserAspect; +use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\IpAnonymizationUtility; @@ -39,8 +40,15 @@ public function setupOnce(): void private function processEvent(Event $event): void { $userData = []; - $ipAddress = GeneralUtility::getIndpEnv('REMOTE_ADDR'); - if (is_string($ipAddress) && !empty($ipAddress)) { + $ipAddress = null; + $request = $GLOBALS['TYPO3_REQUEST'] ?? null; + if ($request instanceof ServerRequestInterface) { + $normalizedParams = $request->getAttribute('normalizedParams'); + if ($normalizedParams instanceof NormalizedParams) { + $ipAddress = $normalizedParams->getRemoteAddress(); + } + } + if (is_string($ipAddress) && $ipAddress !== '') { $userData['ip_address'] = IpAnonymizationUtility::anonymizeIp($ipAddress); }