Hi,
I've recently upgraded from 1.1.1 to 1.1.8. We had been using 1.1.1 for over a year with no issues.
The upgrade went smoothly but since then the notification emails randomly have http://www.example.com and a filesystem path for the view issue URL instead of the correct server name/path. E.g.:
http://www.example.com/usr/local/apache2/htdocs/mantis/core/view.php?id=2161
Instead of:
http://<ourserver>/mantis/view.php?id=2161
At a very rough guess this happens something like 1 in 20 emails and affects the link to the issue plus any links to notes e.g.:
http://www.example.com/usr/local/apache2/htdocs/mantis/core/view.php?id=2161#c8606
It seems to be only in the emails. Viewing the issue via the web front-end so far appears to be fine i.e. any embedded links to other issues in the notes use the correct URL even though those same links are sometimes wrong in the emails.
We have SVN integration via the post-commit hook and checkin.php script. It is possible that this error only occurs when emails are triggered through that mechanism but this normally works OK.
Any ideas?!
Jon
1.1.8 URL in emails occasionally uses example.com
Moderators: Developer, Contributor
Re: 1.1.8 URL in emails occasionally uses example.com
set $t_path, $g_path and $g_short_path.
Re: 1.1.8 URL in emails occasionally uses example.com
Thanks!
I looked through the code and it seems that just setting $g_path in config_inc.php to http://<ourserver>/mantis is sufficient and it certainly seems to have fixed it.
The problem looks like this code in config_defaults_inc.php fails to find the correct URL when called from command line:
Which isn't surprising as we're not going through the webserver.
What is surprising is that it worked before the upgrade to 1.1.8. Perhaps it got g_path from the database in earlier versions?
Anyway, hope this helps anyone else with the same issue!
I looked through the code and it seems that just setting $g_path in config_inc.php to http://<ourserver>/mantis is sufficient and it certainly seems to have fixed it.
The problem looks like this code in config_defaults_inc.php fails to find the correct URL when called from command line:
Code: Select all
if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) { // Support ProxyPass
$t_hosts = split( ',', $_SERVER['HTTP_X_FORWARDED_HOST'] );
$t_host = $t_hosts[0];
} else if ( isset( $_SERVER['HTTP_HOST'] ) ) {
$t_host = $_SERVER['HTTP_HOST'];
} else if ( isset( $_SERVER['SERVER_NAME'] ) ) {
$t_host = $_SERVER['SERVER_NAME'] . $t_port;
} else if ( isset( $_SERVER['SERVER_ADDR'] ) ) {
$t_host = $_SERVER['SERVER_ADDR'] . $t_port;
} else {
$t_host = 'www.example.com';
}
$t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) );
# Remove /api/soap/ from the path to handle the case where the config_defaults_inc.php is included from the
# soap api.
$t_soap_api_path = '/api/soap';
$t_soap_api_path_pos = strpos( strtolower( $t_path ), $t_soap_api_path );
if ( $t_soap_api_path_pos !== false ) {
if ( $t_soap_api_path_pos == ( strlen( $t_path ) - strlen( $t_soap_api_path ) ) ) {
$t_path = substr( $t_path, 0, $t_soap_api_path_pos );
}
}
if ( '/' == $t_path || '\\' == $t_path ) {
$t_path = '';
}
$g_path = $t_protocol . '://' . $t_host . $t_path.'/';
What is surprising is that it worked before the upgrade to 1.1.8. Perhaps it got g_path from the database in earlier versions?
Anyway, hope this helps anyone else with the same issue!