Global Redirect fails if Drupal is installed inside a subdirectory

foutrelis - July 4, 2008 - 16:59
Project:Global Redirect
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:nicholasThompson
Status:closed
Description

globalredirect.module: line 25: if ($_SERVER['SCRIPT_NAME'] != '/index.php') return false;

That line always returns false on my site and I think it's because my installation is inside a subdirectory, so $_SERVER['SCRIPT_NAME'] is actually "/myfolder/index.php".

It seems sensible to use base_dir().'index.php' instead. Attached for review is a patch that does that.

AttachmentSize
globalredirect_base_dir.patch695 bytes

#1

nicholasThompson - July 4, 2008 - 19:59
Priority:normal» critical
Assigned to:Anonymous» nicholasThompson
Status:patch (code needs review)» patch (reviewed & tested by the community)

Ah crap - good point!

I'll commit this asap!

#2

foutrelis - July 19, 2008 - 16:46

It's been two weeks and as far as I know, this bug still exists in 5.x-1.3-1 which was released four days after your reply.

Please look into it when you have time. :)

#3

sethcohn - July 22, 2008 - 19:10

Bump. I got bit by this during an upgrade of the module into a development subdirectory install. Please commit this ASAP, as it completely stop redirection without it if your site is not at the webroot directory.

#4

sethcohn - July 23, 2008 - 16:20
Status:patch (reviewed & tested by the community)» patch (code needs work)

OOPS! Important Correction:

You CANNOT use base_path(), because common.inc isn't called by hook_init.

Per http://drupal.org/node/174366#comment-709393
You can (and likely should) use:

$GLOBALS['base_path'] instead.

#5

sethcohn - July 23, 2008 - 16:48

Better issue for more documentation on why you can't use base_path()

#219916: Call to undefined function base_path()

#6

foutrelis - July 24, 2008 - 14:32
Status:patch (code needs work)» patch (code needs review)

Great catch sethcohn! I updated the patch to use $GLOBALS['base_path'].

AttachmentSize
globalredirect_base_dir_globals.patch705 bytes

#7

nicholasThompson - July 30, 2008 - 15:02
Version:5.x-1.3» 5.x-1.x-dev
Status:patch (code needs review)» fixed

Committed to latest DEV release - will appear in next official release...
http://drupal.org/cvs?commit=130598

#8

Anonymous (not verified) - August 13, 2008 - 15:04
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.