Description:
Mobile Cache fixes common issues with mobile device detection being incompatible with Drupal's caching system. This module performs device detection using the Mobile_Detect class (mobile_detect.module is a dependency), sets a cookie containing the results, and appends a query to the request URI which can generate up to 3 different cached pages for mobile, tablet and desktop devices.
The module also provides the capability to define an alternate theme for mobile devices (and, optionally, tablets) and switch to that theme based on a visitor's device.
There are many other mobile-oriented modules available (including theme switching), but they often do not work with page caching enabled, or require replacement of the cache backend in order to do so. This is problematic for users of alternate caching systems like memcached.
This module may be used as a caching fix for other mobile-oriented modules, or as a lightweight, architecturally different replacement for mobile theme switching modules.
Project Page
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/acy76/1962696.git mobile_cache
Reviews of other projects:
http://drupal.org/node/1871326#comment-7277864
Comments
Comment #0.0
acy76 commentedfixing git clone url
Comment #1
jongagne commentedYou still have a master branch so remember to get rid of it and correctly set up a default branch. Information on how to do both of these can be found here and here. Remember to remove the version data in the .info file, Drupal packages that automatically. Code snipper also found some problems:
Comment #2
acy76 commentedThanks for the review. Fixed the branches, and got code sniffer down to 1 error that I can't seem to get rid of (regarding @return positioning and comments) - if I do it one way, it wants the other way, and so on. Willing to clean up if someone can explain what is wrong.
Comment #3
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #4
yanniboi commentedHey acy76,
I've had a quick look at the return error its throwing your way. Have you tried changing :
to something like this:
I dont think the return normally needs to be given a name...
Comment #5
balintcsaba commentedHi guys,
Before i will check the code please fix the issue.
yanniboi you forgot to put back the status of the project to "needs work". This is important for the owner to see what to do.
Please check how to Apply for full projects.
Comment #6
balintcsaba commentedFix the coding standard issue.
Comment #7
yanniboi commentedThanks balintcsaba!
Comment #8
acy76 commentedyanniboi, good catch - of course it makes sense not to specify a variable name there. i have addressed the issue and the sniffer seems to complete without errors. thanks.
Comment #9
balintcsaba commentedCoder Review
mobile_cache.module
Line 114: the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead [security_12]
$request_string = substr($_SERVER['REQUEST_URI'], -8);
Line 179: the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead [security_12]
if (isset($_SERVER['REQUEST_URI'])) {
Line 180: the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead [security_12]
if (strpos($_SERVER['REQUEST_URI'], '?') === FALSE) {
Line 181: the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead [security_12]
$_SERVER['REQUEST_URI'] .= ('?' . $str);
Line 184: the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead [security_12]
$_SERVER['REQUEST_URI'] .= ('&' . $str);
Comment #10
acy76 commentedThanks for the review.
I replaced any instances where $_SERVER['REQUEST_URI'] was being read with calls to Drupal's request_uri() function.
Still present are two instances where $_SERVER['REQUEST_URI'] is modified with an added query string based on device type.
The operation of the module depends on this modification to $_SERVER['REQUEST_URI'] and, since the data added to $_SERVER['REQUEST_URI'] is generated and validated by the module, this should pose no risk. I believe coder flagging these last two instances to be a false positive from a security perspective, but welcome any discussion on the matter.
Additionally, the request_uri() function adds IIS compatibility in its checks - my module currently does not support servers other than Apache (although the addition of calls to request_uri() are a start), so I have added this information to the project page and README.
Comment #11
dimitrov.adrian commented1) Try deleting all variables after uninstall the module. You should implement hook_uninstall() and on it to try implementing the hook_uninstall() and delete persistent variables that are comming from the settings.
2) I think hook_requirements() will be good place to put dependancies for '/sites/all/libraries/Mobile_Detect/Mobile_Detect.php'
Comment #12
acy76 commentedGood suggestion re: hook_uninstall - this has been implemented.
I did not implement hook_requirements, however, since mobile_detect is listed as a dependency in the .info file. This should be sufficient (unless I am missing something)?
Thanks for the review.
Comment #13
acy76 commentedChanging status.
Comment #13.0
acy76 commentedtypo
Comment #14
kscheirerLooks good enough. You may want to check out hook_libraries() and the rest of Libraries API - that will let you add the files you need without having to hardcode the path in _mobile_cache_detect(). Also PHP's parse_url funciton and http_build_query are much easier for manipulating url strings.
----
Top Shelf Modules - Enterprise modules from the community for the community.
Comment #15
kscheirerInstead of calling mobile_cache_preboot() from settings.php, can you use hook_boot() instead?
----
Top Shelf Modules - Crafted, Curated, Contributed.
Comment #16
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #16.0
PA robot commentedadding 1 review bonus project
Comment #17
roderik de langen commentedcurrent module (sandbox version) is working nicely for me, would love to have this module approved
Comment #18
acy76 commentedComment #19
klausiPlease don't RTBC your own issues, see the project application workflow: https://drupal.org/node/532400
Comment #20
bogdan1988 commentedHi, acy76, very nice and usefull module. But here are some suggestions.
1) In my case it didn't work out of the box.
This code didn't move me to mysite.com?device=1
In my case $_SERVER['REQUEST_URI'] on front page is equal to '/', so in fact I get $_SERVER['REQUEST_URI'] = '/?device=1';
And no url change. No change no cache rebuild for mobile or tablet.
2) Also we could make some enhancements by adding this code
But anyway it is a great module. Thank you! I hope soon it will be used on some projects. After adding some small changes and testing it is RTBC for me, thanks!
Comment #21
roderik de langen commentedComment #22
kscheirerWell, all my points from #14 and #15 still apply:
But none of those are blocking issues.
Thanks for your contribution, acy76!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
----
Top Shelf Modules - Crafted, Curated, Contributed.