Skip to content

Commit 702aa50

Browse files
tsteursgiehl
andauthoredJan 13, 2023
Make sure to use a cached result when we have it so we wont detect it again (matomo-org#54)
* Make sure to use a cached result when we have it so we wont detect it again * fix tests Co-authored-by: sgiehl <stefan@matomo.org>
1 parent 37d2c7f commit 702aa50

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

Diff for: ‎CachedEntry.php

+2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ public function __construct(string $userAgent, $clientHints, array $values)
3939
// We use some special parsers, which use the cached user agent result and parses it again using client hints
4040
if (!empty($clientHints) && $values['client']['type'] === 'browser') {
4141
$browserParser = new CachedBrowserParser($userAgent, $clientHints);
42+
$browserParser->setCachedResult($this->client);
4243
$this->client = $browserParser->parse();
4344
}
4445

4546
if (!empty($clientHints)) {
4647
$osParser = new CachedOperatingSystemParser($userAgent, $clientHints);
48+
$osParser->setCachedResult($this->os);
4749
$this->os = $osParser->parse();
4850
}
4951
}

Diff for: ‎tests/Unit/DeviceDetectorCacheFactoryTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ public function testGetInstanceFromCacheWithClientHints()
122122
'name' => 'Microsoft Edge',
123123
'version' => '98.0',
124124
'short_name' => 'PS',
125-
'engine' => 'Blink',
126-
'engine_version' => '97.0.4692.71',
125+
// empty because cached result doesn't contain it and engine won't be detected through client hints only
126+
'engine' => '',
127+
'engine_version' => '',
127128
'family' => 'Internet Explorer',
128129
];
129130

0 commit comments

Comments
 (0)