The createUrl() method of a controller doesn’t take care of the Yii::app()->controllerMap.
Example:
I have mapped a module-controller to the root: moduleId = ‘mysitemodule’
'controllerMap'=>array(
'site' => 'mysitemodule.controllers.DefaultController'
)
defaultcontroller->getId() will return ‘site’, because the CWebApplication::createController takes care about the controllerMap and changes the controllers Id.
defaultcontroller->createUrl(‘actionid’) creates a invalid actionUrl ‘mysitemodule/site/actionid’:
A ‘mysitemodule.controllers.SiteController’ will not be found.
A possible solution:
The CController::createUrl() method should not add the moduleId if the controller is mapped to the root.
public function createUrl($route,$params=array(),$ampersand='&')
{
$controllerId = $this->getId();
if($route==='')
$route=$controllerId.'/'.$this->getAction()->getId();
else if(strpos($route,'/')===false)
$route=$controllerId.'/'.$route;
//don't add the module id if the controller is mapped
if(!isset(Yii::app()->controllerMap[$controllerId]) && $route[0]!=='/' && ($module=$this->getModule())!==null)
$route=$module->getId().'/'.$route;
return Yii::app()->createUrl(trim($route,'/'),$params,$ampersand);
}