2009-05-12
Michitux
So far I could see this bug under Solaris using Lighttpd and a user reported exactly the same problem in the IRC channel today, he is using Debian Lenny, Apache 2 and the DokuWiki dpkg: $_SERVER['DOCUMENT_ROOT'] and $_SERVER['SCRIPT_FILENAME'] contain two completely different directories (e.g. the document root is the global document root while the script filename is in the user directory or /var/www/ and /usr/share/dokuwiki/doku.php in the case of the Debian system). Therefore, the following code from inc/pageutils.php that tries to get the script filename completely fails and DokuWiki is unable to extract the page id from the url:
if($conf['basedir']){
$relpath = '';
if($param != 'id') {
$relpath = 'lib/exe/';
}
$script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']);
}elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){
$script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','',
$_SERVER['SCRIPT_FILENAME']);
$script = '/'.$script;
}else{
$script = $_SERVER['SCRIPT_NAME'];
}
I have been able to fix it by replacing the last two alternatives and instead checking for the presence of $_SERVER['SCRIPT_NAME'], but I have no idea if that will work in all setups or if it will cause the same problem on other systems. Another alternative would be to check if the script filename contains the document root and if not to use the other alternative.