CUrlManager does not clear internal rules

In my opinion, the correct way to add additional rules (for example with an application component) to already proccessed rules should be:

$additionalRules = array(...);

foreach ($additionalRules as $rule)


  Yii::app()->urlManager->rules[] = $rule;



In fact, I only have to do:

Yii::app()->urlManager->rules = $additionalRules;


Because the (already proccessed) old rules are still available in CUrlManager::$_rules. This is irritating. Let’s say I have a bunch of default rules which are loaded always (through config). If I now want to drop the default rules and use the ones which are defined over an app componenent, how should I do that? It’s not possible to unset the private var $_rules.

Fix would be:


right before:

		foreach($this->rules as $pattern=>$route)

			$this->_rules[]=new CUrlRule($route,$pattern);



in CUrlManager.

// Should I create a ticket or what you think about this? :)