We just updated from version 1.12 to 2.1 and are experiencing a problem with redirects.

Previously, the path:

desktop-domain/url/alias/to/node

would redirect to:

mobile-domain/url/alias/to/node

Now it redirects to:

mobile-domain/node/nid
(where nid = the nid on the desktop site)

With the way our desktop and mobile sites are set up, this results in 404s or occasionally a redirect to the wrong node.

We tried rolling back through the versions of Mobile Tools--we see the problem with 2.0, 1.14 and 1.13. If we roll back to 1.12 (where we started!), the redirects work as expected.

FWIW, we also updated to Pathauto 6.x-1.5 and Path Redirect 6.x-1.0-rc2 at the same time and wondered if there was an interaction among all these modules. If we roll back to the previous versions of Pathauto and/or Path Redirect with Mobile Tools 2.1, we're still seeing the problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bcobin’s picture

I'm seeing a theme switching problem as well with the 2.x version - in my case, it's simply not working, whereas 1.14 does.

I had been doing upgrades from 1.14 to latest versions (including dev) and found that 2.x simply wasn't changing themes, no matter what I did.

Steps to reproduce:

1. Deactivate and de-install any version of Mobile Tools.

2. Install 2.x - set up mobile URL and desktop URL to be the same.

3. Select theme switching based on mobile device detection.

4. Note that theme switching doesn't work (for iPhone, at least.)

5. Deactivate and de-install 2.x vesrion.

6. Install 1.14. (Ignore the security warning - we're just testing here.)

7. Check settings - make sure that automatic redirection of mobile user isn't selected in Notification/Redirection; as I recall this may cause an infinite loop.

8. Repeat steps 2 and 3.

Note that theme switching happens as expected.

An additional note here: Upon installation of 1.14, I see settings I had entered in 1.14 some time back. So there may be something that's not quite right in the upgrade between module versions.

Spent about two days trying to track this down figuring it had something to do with Domain Manager, which I don't believe is needed and is no longer active on my system. (I have removed the addition to the settings.php file the Domain Manager requires.)

Hope this helps - there's definitely something that's not quite right here. And thank you for this most excellent and necessary module! (Although I still can't find any information on the extra *.info file as to what it should be and where it should go!) Cheers and Happy New Year!

bcobin’s picture

Bumping this...

I still haven't been able to find a solution here - is it possible that there's a module conflict somewhere? There's the imagefield problem with 1.14 and the theme switching doesn't work for me at all with 2.1, so I'm stuck. Any ideas? Thanks much...

Oh - and what's the deal with the extra *.info file? Can't seem to find anything on it... thanks!

kittysunshine’s picture

We haven't found a solution to the issue I reported. Then again, your issue sounds completely different than ours.

bcobin’s picture

Then again, your issue sounds completely different than ours.

Yes, you're correct. I'll open this up as a separate thread - good luck on getting everything working here!

scafmac’s picture

Kittysunshine can you describe how you have the mobile-tools module configured? Are you theme switching based on URL or device type?

I'm currently testing with 6.x-2.1 and have it configured to theme switch based on the URL.

When switching to the Nokia-Mobile theme, the path aliases work fine. If using the iUI or the Mobile theme, it reverts to no path aliases as you describe. I've attributed it as a theme issue with those two themes, but have not dug into it.

So what theme are you switching to & have you tried other mobile themes?

kittysunshine’s picture

Good question -- should have included that information in my initial report.

We are doing URL switching only.

We do not have theme switching enabled. We're not using mobile roles. We're using Mobile Tools to handle the device detection.

Just to clarify, the actual device detection and redirection is working just fine -- the module seems to using node/### paths rather than our URL aliases when redirecting.

Let me know if there's more information I can give you to help troubleshoot!

scafmac’s picture

Hmm, that's curious.

So just to test, I've disabled the theme switching on my test site. All content types use path aliases with auto path alias. I'm using a customized Zen-based theme. I can't recreate the problem you describe. All of my menu & links continue to point to the path aliased URLs. None of them are reverting to "node/#".

Do you have any caching enabled?

What are you using for a theme?

Is your mobile & "desktop" site the same Drupal install, only with different URLs? That's what I'm doing on my test site, it's a single Drupal install. The mobile tools URL configuration is set to:
mobile: mtest.example.com/test;
desktop: webtest.example.com/test

kittysunshine’s picture

Nope, no caching and no CSS or Javascript optimization, but we do have page compression enabled.

We're also using a custom Zen-based theme and our main and mobile sites are a single Drupal install. Our URL configuration is set to:

Mobile: m.example.com
Desktop: www.example.com

We have automatic redirection enabled and I think the only other Mobile Tools setting we haven't mentioned is the "Redirection cookie lifetime," which we have set to 1800.

Curious, indeed!

Are you also on Pathauto 6.x-1.5 and Path Redirect 6.x-1.0-rc2 on your test site?

Any other leads? Or other suggestions of what we might try?

scafmac’s picture

Pathauto 6.x-1.4 & no path redirect module installed.

kittysunshine’s picture

Still having this problem. Any suggestions?

thekevinjones’s picture

i had this problem using the current dev version of mobile tools, and i'm not sure why it happened. i uninstalled the module and reverted back to 6.x-2.2 and it worked. essentially what was happening for us was:

user on mobile phone ---> gets mobile site (m.site.com) ---> clicks on 'view full site' and gets full site (site.com?device=desktop) ---> clicks on new link in full site and gets taken back to mobile version with /node/230040 instead of path.

it seems like it was just an issue of the redirection cookies holding their session long enough, but i'm not entirely sure.

our settings are (incase this helps)

mobile url: m.site.com
site url: site.com
enable url redirection for mobile
redirection cookie: 2555000
theme switching between the two
using caching override found in mobile_tools_cache.inc
mobile tools to handle device detection

hope this helps, but after typing it i realize i didn't really give you any good information.

techmunk’s picture

Version: 6.x-2.1 » 6.x-2.3

We fixed this by modifying the mobile_tools_get_redirect_url() function in mobile_tools.module

At the end of that function, change:

  $url = url($base . '/' . $_GET['q'], array('query' => $query));
  return $url;

to:

  $url = url($base . url($_GET['q'], array('query' => $query)));
  return $url;
kittysunshine’s picture

Thanks, techmunk! That change solved the problem for us, too, and we're finally able to update to the latest version of the module.

Majdi’s picture

Thanks , #13 solve my problem

realityloop’s picture

Status: Active » Needs review
FileSize
523 bytes

#13 works, here is a patch for it

richardhayward’s picture

Status: Needs review » Reviewed & tested by the community

We have reviewed and tested the patch provided by realityloop on our development environment and will be going live with this next week.

johndiraviyam’s picture

Patch file will not work in localhost setup. when it is redirecting from desktop to mobile device, it will not redirect properly. so, use the below script.. it will resolve the issue..

<?php
$base = preg_replace('{/$}', '', $destination_url);
 $currentUrl= url($_GET['q'], array('query' => $query));
 $currentPath=str_replace(base_path(),"/",$currentUrl); 
  $url =  $base . $currentPath ;
?>
Alperian’s picture

I can't thank you enough for this fix. I am so grateful :o)

minorOffense’s picture

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

Committed to dev.

ekidman’s picture

Worked perfect - thank you for the fix!!!

ekidman’s picture

The solution in #13 works for me, thanks again. However, I just noticed another issue with the redirect when it comes to a node with multiple aliases. It seems that when the url is constructed after the redirect, it automatically uses the preferred alias for the node, even if the user typed in one of the other aliases. For ex:

node/### has 3 aliases

page/a (preferred)
page/b
page/c

If someone goes to www.mydomian.com/page/c, mobile tools automatically redirects them to the preferred alias, leaving them at m.mydomain.com/page/a. It still brings them to the correct node, but it's interfering with some of our URL tracking on webforms.

Any ideas? Or can anyone replicate this?

ekidman’s picture

I believe I found the solution for the issue I stated above. I'm not a PHP whiz, so if any improvements can be made, feel free to chime in and let me know. But for anyone having this issue, I updated the code in #18 as such:

//create the path and reassemble
  $addr  = ltrim($_SERVER['REQUEST_URI'], '/');
  $base = preg_replace('{/$}', '', $destination_url);
  $currentUrl= url($addr, array('query' => $query));
$currentPath=str_replace(base_path(),"/",$currentUrl);
  $url =  $base . $currentPath ;
  return $url;

The $_SERVER['REQUEST_URI'] is what will actually grab the correct alias and bring it across. I added in the $addr variable to get rid of an extra leading slash (url's were appearing as mydomain.com//my/alias).