Is it a nonsense expression?

when read the source of yii framework,I found a expression which has not any affect for program.The expression located in CWebApplication line 541.

protected function init()


{


	parent::init();


	// preload 'request' so that it has chance to respond to onBeginRequest event.


	$this->getRequest();


}

here expression, $this->getRequest(),has not any affect.

I dont konw if I take a mistake. Everyone know about it ,pls tell me the truth!

Thanks a lot!

the comment has show you the reason. :lol:

most components of CWebApplication(which often extends from CApplicationComponent) is lazy load, means that it will be loaded only you first use it (Yii::app()->componentId or Yii::app()->getComponentId());

request is core component it should be preloaded , so you see the code is :lol:

you can also config which components should be preloaded in main.php (CWebModule also has this property)




'preload' => array('componentId1' , 'componentId2'....),



Of course it has effect. :)

It doesn’t read return parent::init()

But here is only for request. In the registerCoreComponent and preload Step,the request have already initialized and save into _component variable.

Here, when we run the expression,the request component was saved in the _component varible. The whole process contain no initialized step.

registerCoreComponent() and preloadComponents() you 'v saw both did not create the request component , the former only register the config of request component , the latter use CModule::preload to init every component (which you can config it in main.php for both CWebApplication and CWebModule). the only thing wich can cause the component to initialized is CModule::getComponent