1

I'm developing a site that uses the Mobile Tools module to switch between a "desktop" and "mobile" theme. The mobile theme is implemented using the jquerymobile module and s sub-theme of JQM theme.

Unfortunately, the mobile theme will not load any external javascript files that are inserted by other modules (Google Analytics, Facebook Connect). These work fine on the "desktop" theme, but just don't load at all on the mobile theme, so I'm not getting any Google Analytics stats for views on that theme, nor can I implement Facebook Connect login.

According to the jquerymobile docs, there are some issues with the loading of scripts because of the AJAX page loading feature in jquerymobile, but I've turned that off, so every page is its own complete page request.

I am using version 1.0b2 of the jquerymobile library, and gently hacked the jQuery Update module to provide version 1.6.2 of jQuery, since that is a requirement for that version of jquerymobile.

1

The problem turned out to be that a call to the in_array() function in the jquerymobile module did not use the optional third parameter for strict type comparison, so array keys that were strings were getting cast to the integer zero when compared to another zero, and returning true.

The fix was to add the TRUE parameter to the call to in_array.

Here is a quick sample that proves the problem:

<?php

$haystack = array('foo', 'bar', 'baz', 'bat');

$needle = 0;

$test = in_array($needle, $haystack); // same as in_array($needle, $haystack, FALSE)

var_dump($test); // bool(true)

$test2 = in_array($needle, $haystack, TRUE);

var_dump($test2); // bool(false)

?>

Patch file is uploaded on the drupal.org issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.