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').

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrisrockwell created an issue. See original summary.

AohRveTPV’s picture

With 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?

rbrandon’s picture

This 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.

rbrandon’s picture

Re-Uploading patch that didn't upload correctly.

rbrandon’s picture

Additionally, a patch against the alpha2 build if you need it.

AstonVictor’s picture

Status: Active » Closed (duplicate)