View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009577 | mantisbt | installation | public | 2008-08-26 11:23 | 2010-09-19 03:12 |
Reporter | dominik | Assigned To | jreese | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | duplicate | ||
OS | CentOs | OS Version | 4.X | ||
Product Version | 1.2.0a2 | ||||
Summary | 0009577: "Wrong" Links when using symlink for Mantis directory | ||||
Description | I installed Mantis in a directory named mantis-1.2.0a2 and created a symlink called mantis which links to mantis-1.2.0a2. The idea is that Mantis can be always accessed by calling https://xyz.com/mantis and with the symlink one can "switch" between the different versions of mantis (eg /mantis => /mantis-1.2.0a1 | /mantis => mantis-1.2.0a2). I plan to use this for easy Mantis upgrading... So far it works but Mantis will sooner or later (usually right after the login) redirect from https://xyz.com/mantis to https://xyz.com/mantis-1.2.0a2 or when calling a specific page directly it will place links which leads to the "wrong" directory... I found out that the reason for this seems to be the following two lines of code in config_defaults.inc.php: L114: $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', FILE ); According to the PHP-Manual (http://ch2.php.net/manual/en/language.constants.predefined.php) the FILE constant will resolve symlinks, so that makes sence so far. I changed this two lines to use $_SERVER['SCRIPT_FILENAME'] instead of FILE and it works for me now: L114: $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', $_SERVER['SCRIPT_FILENAME'] ); My question is: Is there any reason to use FILE instead of $_SERVER['SCRIPT_FILENAME']? If not, would it be a good idea to make these changes in the Mantis as well? | ||||
Tags | No tags attached. | ||||
Attached Files | config_defaults_inc.php.patch (1,113 bytes)
114c114,120 < $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', __FILE__ ); --- > # with apache use SCRIPT_FILENAME because __FILE__ does resolve symbolic links > if( isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'apache' ) ) { > $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', $_SERVER['SCRIPT_FILENAME'] ); > } > else { > $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', __FILE__ ); > } 116c122 < # Extract the unique directory path of this file relative to the server's documunt root --- > # Extract the unique directory path of this file relative to the server's document root 146c152,158 < $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; --- > # with apache use SCRIPT_FILENAME because __FILE__ does resolve symbolic links > if( isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'apache' ) ) { > $g_absolute_path = dirname( $_SERVER['SCRIPT_FILENAME'] ) . DIRECTORY_SEPARATOR; > } > else { > $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; > } 0001-Minor-enhancement-when-using-symlinks-with-Apache-g.patch (1,151 bytes)
From a47b7e5abcae6ba23dbe45442cd0d3a0dc9f53ca Mon Sep 17 00:00:00 2001 From: Dominik Blunk <dominik.blunk@acc-solutions.ch> Date: Thu, 23 Apr 2009 18:06:02 +0200 Subject: [PATCH] Minor enhancement when using symlinks with Apache (g_absolute_path) --- config_defaults_inc.php | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 82f16f4..89f09db 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -171,9 +171,15 @@ /** * absolute path to your installation. Requires trailing / or \ + * with apache use SCRIPT_FILENAME because __FILE__ does resolve symbolic links * @global string $g_absolute_path */ - $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; + if( isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'apache' ) ) { + $g_absolute_path = dirname( $_SERVER['SCRIPT_FILENAME'] ) . DIRECTORY_SEPARATOR; + } + else { + $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; + } /** * absolute patch to your core files. The default is usually OK, -- 1.6.2.2.1669.g7eaf8 | ||||
Related to 0005137 and 0009266 Unfortunately I cannot add bug relationships thats why I add them here ;-) |
|
$_SERVER['SCRIPT_FILENAME'] is specific to Apache, which is why we do not use it. As a workaround until we can figure out a better way to generate proper paths/urls across all platforms, you can set $g_short_path = "/mantis/" which should take care of any problems you have. |
|
When I revert my changes and set $g_short_path = "/mantis/" as mentioned above https://xyz.com/mantis-1.2.0a2/mantis/view_all_bug_page.php which unfortunately do not work as required... |
|
What about a little selection if apache is used or another webserver? Please let me know if everything is (technically) ok and your thoughts about applying this patch. Thanks! |
|
Added patch created with GIT based on HEAD |
|
The real problem is not in the webserver, but the fact that virtual ($_SERVER['DOCUMENT_ROOT) and physical (FILE) paths are mixed up in config_defaults_inc.php:132. This patch for 1.2.0 stable fixes that: [patch]
I've also posted this patch in http://www.mantisbt.org/forums/viewtopic.php?f=3&t=10266 |
|