Skip to content

Commit

Permalink
Fixed testcase and getID - FS#1908 FS#1831 FS#1838
Browse files Browse the repository at this point in the history
$_SERVER['PATH_INFO'] is used now to determine the page id when using
internal rewriting, in all testcases I've seen so far this variable
was set correctly. There are also a couple of fallbacks if the variable
doesn't exist, $_SERVER['SCRIPT_NAME'] is now preferred instead of
custom path extraction which fails when doku.php is outside the document
root.
  • Loading branch information
michitux committed Mar 2, 2010
1 parent 7caaf84 commit 06368e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _test/cases/inc/pageutils_getid.test.php
Expand Up @@ -76,7 +76,7 @@ function test4() {
$_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
$_SERVER['SCRIPT_NAME'] = '/doku.php';
$_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
$_SERVER['PATH_INFO'] = '/test/dokuwiki';
$_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
$_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
$_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';

Expand Down
14 changes: 7 additions & 7 deletions inc/pageutils.php
Expand Up @@ -23,10 +23,11 @@ function getID($param='id',$clean=true){

$id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null;

$request = $_SERVER['REQUEST_URI'];

//construct page id from request URI
if(empty($id) && $conf['userewrite'] == 2){
$request = $_SERVER['REQUEST_URI'];
$script = '';

//get the script URL
if($conf['basedir']){
$relpath = '';
Expand All @@ -35,15 +36,14 @@ function getID($param='id',$clean=true){
}
$script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']);

}elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['PATH_TRANSLATED']){
$request = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','',
$_SERVER['PATH_TRANSLATED']);
}elseif($_SERVER['PATH_INFO']){
$request = $_SERVER['PATH_INFO'];
}elseif($_SERVER['SCRIPT_NAME']){
$script = $_SERVER['SCRIPT_NAME'];
}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'];
}

//clean script and request (fixes a windows problem)
Expand Down

0 comments on commit 06368e4

Please sign in to comment.