Enabling caching when using the 6.x-2.7 version causes an error to be generated. When requested by a mobile device, the server throws a 500 error and logs the following message:

Call to undefined function _mobile_tools_is_mobile_device()

The issue occurs because the missing function has been refactored in the 2.5 branch in the main code, but the module cache has not been updated.

To reproduce:

Using two a separate mobile and desktop theme, and switching based on device. Enable a mobile detection method (I'm using Browscap, which also has issues, see this issue:

Upgrade module from 2.3 to 2.7 as normal

Ensure that caching has been enabled in the settings,php file, in accordance with the instructions in
$conf['page_cache_fastpath'] = FALSE;
$conf['cache_inc'] = './sites/all/modules/mobile_tools/';

Run update.php

On the performance administration pages, enable caching, setting it to normal.

Put the site online again, switching maintenance mode off.

Any page using the desktop theme displays fine. Any theme using the mobile theme generates a server 500 error and the message
PHP Fatal error: Call to undefined function _mobile_tools_is_mobile_device() in /var/www/html/[site name]/sites/all/modules/mobile_tools/ on line 207

The line is in the following function:
function cache_rewrite_cid(&$cid){
require_once(dirname(__FILE__) . '/mobile_tools.module');
$result = _mobile_tools_is_mobile_device();
$query = $_GET;
$seperator = count($query) ? '&' : '?';
$cid = $cid . $seperator . 'mobile_group=' . $result['group'] . '&device=' . $result['type'];

Proposed resolution

The problem is that the _mobile_tools_is_mobile_device() has been removed during refactoring for 2.5. In the main code, the function has been replaced with a call to a variable:
$browser = module_invoke($device_detection, 'is_mobile_device')

The intent of the original _mobile_tools_is_mobile_device() function is to avoid reliance on external browser detection modules.

The best solution is probably to invoke the new function, which has been moved into the modules/mobile_tools_detection/mobile_tools_detection.module file.
require_once(dirname(__FILE__) . '/modules/mobile_tools_detection/mobile_tools_detection.module');
$result = mobile_tools_detection_detect_mobile_device();

This removes the error, but it does not look like it is caching the site correctly. I am still seeing the desktop site on my mobile device, despite having configured it all correctly.

Members fund testing for the Drupal project. Drupal Association Learn more


extralooping’s picture

as a work around until this problem is resolved, you can use mobile tools for device detection and redirection only and then use Domain Access / Domain Theme for theme switching, which supports caching...
works well for me

c4doug’s picture

Priority: Major » Critical
826 bytes

This bug renders any site that uses the to be non-functional.

The attached patch updates the cache_rewrite_cid() function in to require the mobile_tools_detection module and call mobile_tools_detection_detect_mobile_device instead of the old, non-existant function _mobile_tools_is_mobile_device.

I don't know what should be done if the website is not using mobile_tools_detection for the site-type-detection, but this fixes pure mobile_tools usage.

c4doug’s picture

Status: Active » Needs review

status update

wmad’s picture

#2 worked for me.

Devin Carlson’s picture

Status: Needs review » Fixed

Thanks for the patch!

Committed to 6.x-2.x.

Status: Fixed » Closed (fixed)

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

HS’s picture

This issue still exists in the 6.x.2.7 release, right?