Hi,

I've installed mobile tools 6.X-2.X-dev and browscap-6.x-2.x-dev. I've active both in Modules. No problem.

But when I choose Browscap in the Mobile Tools options I get this error.

Fatal error: Call to undefined function browscap_get_browser() in /home/escapade/public_html/sites/all/modules/mobile_tools/modules/mt_browscap/mt_browscap.module on line 20.

Can you help?

Thank you in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dallasw1983’s picture

FileSize
3.47 KB

I had the same problem with version 6.x-2.7, I'm not sure whats causing it because I can comment out line 20 and run browscap_get_browser() and it returns an array.

So for a work around I did...
Comment out line 20
#$user_agent = browscap_get_browser();
Add the function from the module browscap/browscap.module (version 6.x-2.0) line 76 to line 126 and rename the function to tmp_browscap_get_browser().
Then add below the new function $user_agent = tmp_browscap_get_browser();

I'm not 100% sure on how this overall affects the site, but it got my mobile site back up and running with no global fatal errors and figure it's safe since it's using the same code as the browscap module.

I've also attached mt_browscap.module which is named mt_browscap.txt for upload purposes.

Hope this helps!

AlfTheCat’s picture

@dallasw1983,

Thanks for this, I had the same issue using 2.x-dev of mobile tools and the 2.0 version (D6) of browscap. Your updated module file fixed my issue too.

greggmarshall’s picture

While the fix appears to resolve the issue, it bothers me that the code needs to be duplicated. I thought it might be a module weight issue, so I tried setting browscap's weight to -5, in theory that should load it before mobile tools (default weight of 50) and mt_browscap (default weight of 0), which did not resolve the problem.

KropotkinThinks’s picture

Like Alf, I had the same issue. I had it with both the mobile_tools 2.3 and the 2.7 module. The Browscap 1.5 version worked fine, but upgrading to 2.x kills the site.

However, the issue only seems to appear when caching is enable. Disable caching and everything works fine. Enable caching and the site dies, with the undefined function message. Clearing the cache does not appear to help the situation either.

So the issue appears to reside in the way the functions are cached. But I haven't figured out exactly how yet.

Thanks for the fix, that is a big help.

hwasem’s picture

Thank you for this fix.

Anonymous’s picture

Hi Guys, I solved problem adding following line to mt_browscap.module file:

include_once dirname(__FILE__).'/../../../browscap/browscap.module';

Same problem happend to mobile_switch module has been solved adding code portion to mobile_switch.module

edonnelly’s picture

#6 solved the issue for me, and I really appreciate it because the site was just error-ing out on every page, including all admin pages.

greggmarshall’s picture

I wonder if a better solution to #6 might be
drupal_load('module', browscap);

wmad’s picture

Yes, #8 worked for me. I agree that it is a better solution.

edonnelly’s picture

I updated my module to 6.x-2.7+3-dev (2013-Feb-22) today, got the same error again, and #8 worked for me. Thanks again!

possiBri’s picture

Also came across same issue and #8 worked like a charm! Thanks guys =]]

mikl’s picture

Status: Active » Needs review
FileSize
1.47 KB

I've created a patch including the solution from #8, as well as a fix for erraneous mobile detection when used with Browscap 2.x.

Anonymous’s picture

Priority: Normal » Critical

Marking this as "critical" since "Critical bugs either render a system unusable". I think WSOD and no update.php access qualifies.

The patch in #12 is appropriate and works well. I had tried adjusting the weight of the module to no effect. Thanks for the patch! Much appreciated.

nateman332’s picture

Status: Needs review » Reviewed & tested by the community

#8 worked for me. I'll change this to "reviewed an tested by the community" since it seems that it's worked for people. (change it back if I'm wrong) :)

EvanDonovan’s picture

I can confirm that the patch in #12 works.

alexmoreno’s picture

#8 tested here too. It works like a charm.

iaha’s picture

Patch in #12 works for me.

pribeh’s picture

Running browscap with mobile tools took down my site. Patch in #12 resolved the issue quite nicely. Danke!

chinita7’s picture

Issue summary: View changes

I had the same issue. #12 works for me. Thank you!

apaderno’s picture

Status: Reviewed & tested by the community » Closed (outdated)

I am closing this issue, as it's for a Drupal version no longer supported.