Got the following notices after updating to the latest dev version:

# Notice: Undefined index: q in globalredirect_init() (line 208 of [path]\sites\all\modules\globalredirect\globalredirect.module).
# Notice: Undefined index: q in globalredirect_init() (line 210 of [path]\sites\all\modules\globalredirect\globalredirect.module).

Comments

nicholasthompson’s picture

Thanks - I'll take a look into this.
http://drupalcode.org/viewvc/drupal/contributions/modules/globalredirect...

Looks like this would probably only ever happen on the frontpage, when there is no "q"...?

adrian drupal’s picture

My first time in Drupal, I'm trying to bring my blog from Squarespace, Drupal 7 all is working well until today trying to install Global Redirect, this message appears.

Notice: Undefined index: q in globalredirect_init() (line 208 of /home/xxxxxx/xxxxxx_html/sites/all/modules/globalredirect/globalredirect.module

I have no idea how to solve this, anyone know if it resolved soon, I think this module is required to bring my content.

Thank you.

tsvenson’s picture

Its much worse than that. You can't open any /admin pages, wither direct or in overlay. After some time the browser shows an error saying that it it can't open a page due to that the redirect will never be resolved.

I tried to manually disable the module by changing status from 1 to 0 in the system table, but I still got the above errors. Only way I could get into admin again was after I commented out the if's in the module.

nicholasthompson’s picture

@tsvenson: That's interesting. I'll have to take a look at that. You using 7.0-ALPHA6?

tsvenson’s picture

Yes, I'm on Alpha 6. Ping me if/when you need help testing.

nicholasthompson’s picture

Interestingly, I cannot replicate this on my Lighttpd devbox...

dave reid’s picture

Do you have E_NOTICE errors enabled in error_reporting?

nicholasthompson’s picture

It's not an error reporting issue...

If I add:

dpm($_REQUEST);

above line 208, my Lighttpd devbox (Lighttpd 1.4.26 and PHP 5.3) shows that $_REQUST['q'] exists and mimcks the "alias" (or raw) path, wheras $_GET['q'] is the source.

On my other devbox, running Apache 2.2 and PHP 5.2, $_REQUEST contains an entirely different set of values...

Global Redirect running on D7.0.alpha6 with Apache 2.2 and PHP 5.2

I am still investigating as to why this is happening...

NOTE: You must return; just after doing the dpm() otherwise you'll never see it ;)

nicholasthompson’s picture

Title: Undefined index on line 208/210 after update to latest det » Undefined index on line 208/210. Caused by Drupal 7 handling Clean URL's differently to Drupal 6.
Priority: Normal » Critical
Status: Active » Needs work

Drupal 7 handles Clean URL's differently.

In Drupal 6, the RewriteRule pushes the request uri into index.php?q=$1. This is why $_GET['q'] and $_REQUEST['q'] are both set.

In Drupal 7, the RewriteRule simply sets all URL's to go to index.php. drupal_environment_initialize then handles the URL via request_path.

This difference in behaviour means there is no $_REQUEST['q'].

nicholasthompson’s picture

In addition, my Lighttpd box only works because my Lua Script for Clean URL's mimicks Drupal 6's htaccess. I guess it's a miracle Drupal 7 works on my devbox at all! ;-)

tsvenson’s picture

My local dev environment is Wampserver 2.0h (since 2.0i comes with PHP5.3) on a Windows XP box.

The modules I am have enabled on it is:

Drupal 7.0-alpha6

AddThis Button 7.x-2.x-dev (2010-Jul-11)
Advanced help 7.x-1.x-dev (2010-Jul-15)
Backup and Migrate 7.x-2.x-dev (2010-Jul-11)
Comment Notify 7.x-1.x-dev (2010-Jul-11)
Comment subjects 7.x-2.x-dev (2010-Jul-11)
External Links 7.x-1.11
Flexible Blogs 7.x-1.x-dev (2010-Jul-11)
Follow 7.x-1.x-dev (2010-Jul-11)
Google Analytics 7.x-1.x-dev (2010-Jul-11)
Image Resize Filter 7.x-1.x-dev (2010-Jul-11)
Insert 7.x-1.0-alpha1
Mollom 7.x-1.0-alpha2
Path redirect 7.x-1.x-dev (2010-Jul-11)
Pathauto 7.x-1.x-dev (2010-Jul-11)
Site verification 7.x-1.x-dev (2010-Jul-11)
Token 7.x-1.x-dev (2010-Jul-11)
Views 7.x-3.x-dev (2010-Jul-15)
Wysiwyg 7.x-2.x-dev (2010-Jul-11)
XML sitemap 7.x-2.x-dev (2010-Jul-11)

As you can see i use both Pathauto and Path redirect. Maybe this is some kind of incompatibility between them and Global redirect?

I did install everything fresh on D7 alpha 6.

One other thing is that I did test Global redirect on D7 alpha 5 a few weeks back and it didn't trigger any errors. Maybe they changed something between those two alphas that causes this problem.

Hope this might help so you can recreate this.

nicholasthompson’s picture

Thanks for that Thomas.

The issue is nothing to do with any other module - it is simple a failure to comply with a complete change in how URL's are handles in Drupal 7. My fault :-)

nicholasthompson’s picture

Well that didn't go well - first test run after "fixing" it... 56 passes, 54 fails and 2 exceptions!

EDIT: Of course... it would help if I gave the test bot the devbox password ;-)

tsvenson’s picture

Aha. Well as you saw in my edit, I didn't get any errors when I tried your module in alpha 5.

Glad we could sort it out. Let me know when you need help testing any fix and I will gladly help out.

nicholasthompson’s picture

Status: Needs work » Needs review

I've committed several major fixes to the Drupal 7 branch - care to test?

tsvenson’s picture

Yepp, testing now.

Updated fine and no more error messages on screen or in log.

I also tested redirection of non clean URL and these are my results:

Settings used/turned on:

Deslash - On
Non-clean to Clean - On
Remove Trailing Zero Argument - Enabled for all pages
Case Sensitive URL Checking - On
Taxonomy Term Path Handler - On

example.com/node/1 -> example.com/node/1
example.com?q=node/1 -> example.com/?q=node/1

Only diff is the / added in the second URL.

I also tested with Add Canonical Link turned on, but with the same results.

Also tested both as anonymous and authenticated user with same results.

Tested in both Firefox 3.6.6 and Chrome with same results.

Canonical is getting blue (Firefox) and pointing to clean URL. However it does so with the Add Canonical Link both on and off so I guess that comes from core or the Pathauto module.

No warnings or errors shown/logged during test.

Not sure what else I can test to try and figure out what's going on here.

eule’s picture

hi

this bug is presented in the 7.13 tested on a drupal alpha 6

# Notice: Undefined index: q in globalredirect_init() (line 208 of ./modules/globalredirect/globalredirect.module).
# Notice: Undefined index: q in globalredirect_init() (line 210 of ./modules/globalredirect/globalredirect.module).

drupal crashs total and i cant join any site.

del and install the new dev works fine

thanks for the work

lpalgarvio’s picture

getting the same notices.
site becomes unnavigatable after enabling the module.

Global Redirect 1.3-alpha1
Drupal 7 alpha6

then if i replace the 7-x-1.3-alpha1 version with the 7-x-1.x-dev, it starts working again and i get no more notices

Global Redirect 1.x-dev
July 17, 2010 - 01:07
Drupal 7 alpha6

looks like its fixed

dave reid’s picture

thekevinday’s picture

I am also having this problem and a workaround the error message is changing

<?php
  if ($_REQUEST['q'] != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $_REQUEST['q']) != '/' || $settings['deslash']) {
      drupal_goto($alias, $options, 301);
    }
  }
?>

to

<?php
  if (isset($_REQUEST['q']) && $_REQUEST['q'] != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $_REQUEST['q']) != '/' || $settings['deslash']) {
      drupal_goto($alias, $options, 301);
    }
  }
?>

for the file: globalredirect/globalredirect.module at line 208.

For some reason q is not defined in _REQUEST, this may be related to how the dashboard javascript is handling the url changes.

#9 seems to explain this.

So the question is, is it correct to use a isset() here as a solution or is the bug elsewere?

caschbre’s picture

Just to confirm I had the same scenario / solution as #18 above.

jzornig’s picture

I'm also getting this on d7-rc2. If I enable clean URLs and install Global Redirect the site becomes unusable.

nihonsei’s picture

Version: 7.x-1.x-dev » 7.x-1.3-alpha1

I'm also getting this on d7-rc3.

CmKeen’s picture

Same thing on d7-rc4

jamesoakley’s picture

subscribe

krato’s picture

I'm also getting this on Drupal 7 final version. Please, fix it, it blocks me from using Drupal 7.

jamesoakley’s picture

Status: Needs review » Active

Marking this as Active (instead of "Needs Review"), as the patches committed at #15 were a long time ago and it appears people are still finding this issue even with those changes.

jamesoakley’s picture

Status: Active » Reviewed & tested by the community

Actually, my previous post (#27) was wrong. The fixes committed at #15 did repair the problem - I've just tested against the 7.x-1.x-dev, and the problem is gone. (My mistake for assuming that an alpha from last July could not have been the most recent release).

Now that D7 is live, please could we have a formal release (beta if necessary) for this module, so that people downloading D7 don't install the 7.x-1.3-Alpha1 version of this module by mistake and lose access to their site as a result?

nicholasthompson’s picture

Im just confirming the simpletest runs and I'll push out a 1.3 release so it's inline with 6.x.

nicholasthompson’s picture

Status: Reviewed & tested by the community » Fixed

I have pushed out a 1.3 release which is based on the dev branch as of today.

http://drupal.org/node/1015896

jamesoakley’s picture

:-)

Status: Fixed » Closed (fixed)

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

  • Commit e12b59c on 7.x-1.x, master, 8.x-1.x by nicholasThompson:
    Fixing spree for the Drupal 7 branch to make it work with Drupal 7's new...