Closed (fixed)
Project:
Browscap CTools
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Dec 2012 at 14:52 UTC
Updated:
26 Apr 2013 at 13:30 UTC
Jump to comment: Most recent
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
Comment #1
Jeff Burnz commentedIsn'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.
Comment #2
hmalak commentedHello 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.
Comment #3
Jeff Burnz commentedThis 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.
Comment #4
hmalak commentedThank you Jeff.
Comment #5
waddles commentedYup, patch in browscap's import.inc (#1868808: False/true not converted to 0/1 during browscap.ini import) fixed it.
Comment #6
mondrakePlease 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
Comment #7
hmalak commentedHello mondrake, how can I do that? Thank you.
Comment #8
mondrake@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!
Comment #9
acy76 commentedThe 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.
Comment #10
Anonymous (not verified) commentedI'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)
Comment #11
Jeff Burnz commentedI pushed this to dev.
Comment #12.0
(not verified) commentedAdded strtolower()