diff --git a/src/Integration/RequestIntegration.php b/src/Integration/RequestIntegration.php index 4238b457c..d4ab50ce1 100644 --- a/src/Integration/RequestIntegration.php +++ b/src/Integration/RequestIntegration.php @@ -137,7 +137,7 @@ private function processEvent(Event $event, Options $options): void if ($options->shouldSendDefaultPii()) { $serverParams = $request->getServerParams(); - if (isset($serverParams['REMOTE_ADDR'])) { + if (!empty($serverParams['REMOTE_ADDR'])) { $user = $event->getUser(); $requestData['env']['REMOTE_ADDR'] = $serverParams['REMOTE_ADDR']; diff --git a/tests/Integration/RequestIntegrationTest.php b/tests/Integration/RequestIntegrationTest.php index 266405d90..cea34cb57 100644 --- a/tests/Integration/RequestIntegrationTest.php +++ b/tests/Integration/RequestIntegrationTest.php @@ -163,6 +163,24 @@ public static function invokeDataProvider(): iterable UserDataBag::createFromUserIpAddress('127.0.0.1'), ]; + yield [ + [ + 'send_default_pii' => true, + ], + (new ServerRequest('GET', 'http://www.example.com', [], null, '1.1', ['REMOTE_ADDR' => ''])) + ->withHeader('Host', 'www.example.com'), + [ + 'url' => 'http://www.example.com', + 'method' => 'GET', + 'cookies' => [], + 'headers' => [ + 'Host' => ['www.example.com'], + ], + ], + null, + null, + ]; + yield [ [ 'send_default_pii' => false,