Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detecting device type by form factor of client hints #7843

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Nommyde
Copy link
Contributor

@Nommyde Nommyde commented Sep 21, 2024

Description:

In the method \DeviceDetector\Parser\Device\AbstractDeviceParser::parseClientHints,
condition \array_key_exists($formFactor, $formFactors) is always false because $formFactor is a string and $formFactors keys are integers ($formFactors is a list of strings). If we fix just this condition, then $deviceType gets the string value of self::getDeviceName, but it should be an int (we don't need the getDeviceName call)
Then, if we fix that, we see that 'deviceType' field is never used in the \DeviceDetector\Parser\Device\AbstractDeviceParser::parse method, so we need to fill $this->deviceType with it to get advantage of client hints when nothing else helps to detect device type.

I am not sure if the fixture I created fits your conventions, but it detects the described problems and does its job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant