Skip to content

Commit 59a45c6

Browse files
authored
Merge pull request #173 from maxmind/greg/fix-user-agent
Fix handling of user_agent from array
2 parents 3ad51f5 + d7e7f55 commit 59a45c6

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.0.1 (2024-05-02)
5+
------------------
6+
7+
* When calling `withDevice` with an array, an exception was incorrectly
8+
thrown if `user_agent` was set but `session_id` was not set. Reported by
9+
Gregor Kuhlmann. GitHub #172.
10+
411
3.0.0 (2024-04-16)
512
------------------
613

src/MinFraud.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ public function withDevice(
213213
$sessionId = (string) $v;
214214
}
215215
}
216-
if ($sessionId) {
217-
$userAgent = $this->remove($values, 'user_agent');
218-
}
216+
$userAgent = $this->remove($values, 'user_agent');
219217

220218
$this->verifyEmpty($values);
221219
}

tests/MaxMind/Test/MinFraudTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ public function testMissingIpAddressWithoutValidation(string $class, string $ser
380380
);
381381
}
382382

383+
/**
384+
* @dataProvider services
385+
*/
386+
public function testUserAgentWithoutSessionId(string $class, string $service): void
387+
{
388+
$this->createMinFraudRequestWithFullResponse(
389+
$service,
390+
request: ['device' => ['user_agent' => 'test']],
391+
)->withDevice(['user_agent' => 'test'])->{$service}();
392+
}
393+
383394
/**
384395
* @dataProvider withMethods
385396
*/

0 commit comments

Comments
 (0)