not working when drupal is installed in a subdirectory
WiseTeck - September 4, 2008 - 17:00
| Project: | Global Redirect |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | nicholasThompson |
| Status: | needs work |
Jump to:
Description
the fix for Admodule http://drupal.org/node/278199 introduce a new bug. This solution will not work if drupal is installed in subdirectory (eg: htdocs/subfolder/drupal/ ).
In this case the value for $_SERVER['SCRIPT_NAME'] is not 'index.php', but /subfolder/drupal/index.php.
This small patch will fix it.
| Attachment | Size |
|---|---|
| globalredirect-subdirectory.patch | 631 bytes |

#1
This is a good point...
My concern here is if someone (stupidly) calls their nested bootstrap index.php, then this patch will cause issues too.
So, lets take a look at the opions... Drupal could be installed in:
Based on these two scenarios, the modules could then have a bootstrap in...
Your patch solves these issues, but what if a developer releases a module with a bootstrap as...
So essentially - for a given Drupal Install, what's the difference between these two paths?
The latter could (POSSIBLY) be an install of drupal which happens to be nested 6 levels down.
This problem is unlikely and very edge case but I cant help but think there must be a very elegant solution for this!
#2
Yeah, got your point. The ambiguity between
could be solved by using base_path()
If /subfolder/sites/all/modules/mymodule/index.php would be a nested 6 level drupal setup then the base_path would be '/subfolder/sites/all/modules/mymodule/'
so the test should be
if ($_SERVER['SCRIPT_NAME'] != base_path().'index.php') return false;#3
WiseTeck... Not quite... base_path() simply represents the path that the script was called in. It could be root or it could be a module.
I believe the way the Ad module gets around this is to, upon install, store in a variable the location of module itself. This allows it to compare the current URL to the "known" module location.
I'm wondering if this could be a feature of the new globalredirect admin I've added to 5.x-dev... By default the ONLY URL which should have redirects is
base_path() . 'index.php'and this is decided upon module install/update. In the admin area, the site admin can control the paths which ARE allowed to be redirected upon...#4
what about storing the base_path() during installation of the module?
like this:
variable_set('globalredirect_base_path', base_path());
and then in the hook:
$base_path = variable_get('globalredirect_base_path', base_path());
if ($_SERVER['SCRIPT_NAME'] != $base_path.'index.php') return false;
anyone see any problems with this?
#5
gielfeldt: Seems like a sensible solution...
#6
#278615: Global Redirect fails if Drupal is installed inside a subdirectory marked as duplicate.