var_dump() of browscap_get_browser() result shows that the value of $browser['ismobiledevice'] is of type string:

 ["ismobiledevice"]=> string(4) "true"

Therefore the following check will yield false :

  if ($browser['ismobiledevice'] == 1) {

The function should be changed from:

function browscap_ctools_browscap_access_ctools_access_check($conf, $context) {
  $browser = browscap_get_browser();
  if ($browser['ismobiledevice'] == 1) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}

to:

function browscap_ctools_browscap_access_ctools_access_check($conf, $context) {
  $browser = browscap_get_browser();
  if (($browser['ismobiledevice'] === TRUE) || ($browser['ismobiledevice'] == 1) || ($browser['ismobiledevice'] == "1") || (strtolower($browser['ismobiledevice']) == "true")) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}

I have added check for other possible values of true as well just to safeguard.

Comments

Jeff Burnz’s picture

Category: bug » feature
Priority: Critical » Normal

Isn't this a feature request?

You are saying that browscap_get_browser() might return a string "true" or "1", if so then that is surely a bug report against browscap module - it needs to return a bool, always, not a string. I wonder what else it can return if it can return a string, seems a bit much to expect modules to guess what the value might be.

That might answer a lot of other issues I have seen regarding browscap module also, good sluething, I am going to test some more on this and see if we can get a fix into browscap, if possible, otherwise I suppose we need to guess as you suggest in your code.

hmalak’s picture

Category: feature » bug
Priority: Normal » Critical

Hello Jeff, please see my comment #5 on the bug report here #1433936: Mobile browser not detected. I am confirming the same issue for the newest version.
I think it's related. Thank you.

Jeff Burnz’s picture

Priority: Critical » Normal

This looks like the real issue here:

#1868808: False/true not converted to 0/1 during browscap.ini import

I'll leave this as a bug report for now, but I think its pretty clear the issue with with the import script for browscap module.

If someone is having this issue can they try the patch in the above issue and switch this to a duplicate.

hmalak’s picture

Thank you Jeff.

waddles’s picture

Status: Active » Closed (duplicate)

Yup, patch in browscap's import.inc (#1868808: False/true not converted to 0/1 during browscap.ini import) fixed it.

mondrake’s picture

Status: Closed (duplicate) » Active

Please consider marking #1868808: False/true not converted to 0/1 during browscap.ini import as RTBC so it can finally get in a new browscap release. I cannot do it as I am the author of the patch, and RTBC cannot be set by the author.

Thx

hmalak’s picture

Hello mondrake, how can I do that? Thank you.

mondrake’s picture

@hmalak

go to the issue #1868808: False/true not converted to 0/1 during browscap.ini import, post a new comment stating that you reviewed and tested the patch ok, and select from the Status dropdown of the issue settings the value Reviewed and tested by the community.

More info @Status settings for an issue

Thanks and a happy new year!

acy76’s picture

Status: Active » Closed (duplicate)

The patch discussed above fixed this issue for me - I have marked the linked browscap issue as 'reviewed and tested' and will close this report as requested by the developer.

Anonymous’s picture

Status: Closed (duplicate) » Active

I'd like to add that after applying the patch, be sure to download a fresh browsecap data file. (Modules>Browscap>Refresh Browscap Data File then Save Configuration)

Jeff Burnz’s picture

Status: Active » Fixed

I pushed this to dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added strtolower()