Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am using 8.x-3.x-dev and as of today have browscap version 6023. This might be a support request :D.
This is the output from $this->browscap->getBrowser()
:
Array
(
[comment] => Default Browser
[browser] => Default Browser
[browser_maker] => unknown
[version] => 0.0
[majorver] => 0
[minorver] => 0
[platform] => unknown
[ismobiledevice] => 0
[istablet] => 0
[crawler] => 0
[device_type] => unknown
[device_pointing_method] => unknown
[parent] => DefaultProperties
[useragent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
[browser_name_pattern] => *
)
Here is the output from var_dump(get_browser())
:
object(stdClass)[896]
public 'browser_name_regex' => string '~^mozilla/5\.0 \(.*mac os x 10.12.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome/57\..*safari/.*$~' (length=103)
public 'browser_name_pattern' => string 'Mozilla/5.0 (*Mac OS X 10?12*) applewebkit* (*khtml*like*gecko*) Chrome/57.*Safari/*' (length=84)
public 'parent' => string 'Chrome 57.0' (length=11)
public 'platform' => string 'macOS' (length=5)
public 'comment' => string 'Chrome 57.0' (length=11)
public 'browser' => string 'Chrome' (length=6)
public 'browser_maker' => string 'Google Inc' (length=10)
public 'version' => string '57.0' (length=4)
public 'majorver' => string '57' (length=2)
public 'device_type' => string 'Desktop' (length=7)
public 'device_pointing_method' => string 'mouse' (length=5)
public 'minorver' => string '0' (length=1)
public 'ismobiledevice' => string '' (length=0)
public 'istablet' => string '' (length=0)
public 'crawler' => string '' (length=0)
I have copy/pasted the result of $this->browscap->getBrowser()['useragent']
directly into http://browscap.org/ua-lookup and it returns the correct information (platform is 'macOS').
Comment | File | Size | Author |
---|---|---|---|
#5 | platform_unknown_like_collation-2877029-5-alpha2.patch | 958 bytes | rbrandon |
#4 | platform_unknown_like_collation-2877029-4.patch | 850 bytes | rbrandon |
#3 | platform_unknown_like_collation-2877029-3.patch | 0 bytes | rbrandon |
Comments
Comment #2
AohRveTPV CreditAttribution: AohRveTPV commentedWith 8.x-3.x-dev and 6023, I added
print_r(\Drupal::service('browscap')->getBrowser());
to another module, and it gave full output.Does this problem occur just with that particular browser, or any browser you use?
I suppose you are using
$this
because you added the Browscap service using dependency injection?Comment #3
rbrandon CreditAttribution: rbrandon as a volunteer commentedThis looks like an issue with Collation, in some cases the LIKE used to lookup the user agent pattern will be case sensitive. I have added LOWER in my patch which fixes the issue.
Comment #4
rbrandon CreditAttribution: rbrandon as a volunteer commentedRe-Uploading patch that didn't upload correctly.
Comment #5
rbrandon CreditAttribution: rbrandon as a volunteer commentedAdditionally, a patch against the alpha2 build if you need it.
Comment #6
AstonVictor CreditAttribution: AstonVictor as a volunteer and at DevBranch commentedIt's a duplicate of #3105671: User Agent Strings not matching