yiisoft/yii — Issue #431: Bug in CUrlManager for array('/') path
Author: ecesena
Created: 2012-03-02 09:51:56+00:00
State: open

Configuration:
yii 1.1.9 (not checked, but the bug is probably older) within the directory /path/to/yii
my project within /path/to/yii/apps/proj
apache with DocumentRoot="/path/to/yii/apps/proj"
(the bug appears *only* when proj is the root)

CUrlManager configured with {
'urlFormat'=>'path',
'showScriptName'=>false
}
again, showScriptName is fundamental to reveal the bug, otherwise the url is never empty (my temporary solution was in fact to put showScriptName=>true).

Bug:
CController:createUrl( array('/') ) returns the current directory, instead of the root.
(it doesn't return empty, it really constructs the current route, which is wrong).

Solution (CUrlManager.php:325):

if($this->appendParams)
{
$url=rtrim($url.'/'.$this->createPathInfo($params,'/','/'),'/');
+++	if ($url==='') $url='/';
return $route==='' ? $url : $url.$this->urlSuffix;
}

Best, ec