Closed (fixed)
Project:
Mobile Tools
Version:
6.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 May 2011 at 15:23 UTC
Updated:
30 Oct 2012 at 12:51 UTC
Jump to comment: Most recent file
Comments
Comment #1
sunset_bill commentedMore succinctly, what it looks like is that my site seems to use the mobile theme by default when I'm using Browscap for device detection.
SB
Comment #2
sterndata commentedWhat's your full UserAgent string? http://whatsmyuseragent.com/
Comment #3
sunset_bill commentedIt's happening with all of my browsers. Per whatsmyuseragent:
FF
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Safari
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
Chrome
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
First hit on a page in any of these with a clear cache and MT configured to use Browscap for device detection gets me the mobile theme.
thanks,
SB
Comment #4
akoepke commentedI encountered the same issue and have the fix. The cause of this issue is the same as another issue I just logged for the browscap module.
In the mobile_tools/contrib/mt_browscap.module file is the following
The data returned by browscap is all strings, they are not booleans. This means that when evaluated as a boolean it will always return true.
The code above can be replaced with the following
This evaluates the data as a string and works properly.
Comment #5
sunset_bill commentedThat seems to have done it, alright. Thanks!
Comment #6
akoepke commentedI won't call this fixed until something has been committed to the dev version. I am also looking at the code of Browscap to see if the actual data it stores in the database can be changed so that proper boolean evaluations can be done.
Comment #7
akoepke commentedJust thought I would post back with an update. I have had a look at the Browscap module and the way it parses the data is quite simple and a lot of the problems comes from the way that the parse_ini_file function works.
In the browscap module there is a function called _browscap_boolean which is used internally for the boolean evaluations.
Attached to this post is a patch of my changes which also adds in an iPad group as the contrib module didn't have one.
Comment #8
devin carlson commentedBrowscap was fixed in #664424: Values returned as bool with PHP < 5.3 should also be bool with PHP >= 5.3 to properly return the correct information.
Comment #9
chunty commentedUnless I'm missing something I don't think this is fixed...I've got the dev version of browscap installed and I still have the same problem.
Also I think the code replacement suggestion here whilst it may have been correct at one point is now out of date. I think you now need to replace:
on line 23 of mt_browscap.module with:
Comment #10
Drave Robber commentedConfirmed - with the latest 6.x-*.*-dev of both Mobile Tools and Browscap (PHP 5.3.5-1ubuntu7.10), everything is still 'mobile'.
A typical return from
browscap_get_browser()is like this:the relevant part being
["ismobiledevice"]=> string(1) "0".To be more or less safe against possible future changes in
browscap_get_browser()return, I'd suggest a loose comparison against string'0'which would work with int0or booleanFALSEas well:Patch to that effect attached.
Comment #11
Drave Robber commentedAh yes, issue status.
Comment #12
sarvab commentedI ran into this issue as well and would recommend we get this patch applied quickly. The module in it's current state cannot use mt-browscap at all as all browsers will be flagged as mobile.
I made a slight change to the above patch to use !empty instead of isset to be as simple as possible. empty will return TRUE for the integer or string value "0" as well as not existing / false "" etc.
Comment #13
devin carlson commentedFixed with http://drupalcode.org/project/mobile_tools.git/commit/5c3450a.