CWebUser::getReturnUrl() - a little improvement suggestion

Hi there!

As you may know, the property CWebUser::returnUrl will return “/index.php” if there is no explicit url specified. This may be an undesired situation if you’ve set “showScriptName” to FALSE.

The solution is to change the CWebUser::getReturnUrl() to the following:

  public function getReturnUrl($defaultUrl=null)


    return $this->getState('__returnUrl', $defaultUrl===null ? Yii::app()->getHomeUrl() : CHtml::normalizeUrl($defaultUrl));


Note that, if the “showScriptName” parameter is set to TRUE this suggested method is effectively the same as the yii’s current method, because CWebApplication::getHomeUrl() will call CHttpRequest::getScriptUrl() itself.

I suppose the proposed method could take place of the current implementation.