I’m sure this is simple, but until recently I haven’t needed to override much in the framework.
Now I need to override CHttpRequest::normalizeRequest() so I created a class EHttpRequest and placed it in ‘application.components’.
In main.php config is this, so the app is looking in the location where the class is:
'import'=>array(
'application.models.*',
'application.components.*',
),
However, during a trace where the request fails, I can see the app referencing CHttpRequest::normalizeRequest() instead of my overridden function in EHttpRequest.
I can add the ‘class’ key to the ‘request’ component as below but then of course all other request functions will fail.
'request'=>array(
'class'=>'EHttpRequest',
'enableCsrfValidation'=>true,
),
The overridden class is straightforward…
class EHttpRequest extends CHttpRequest
{
protected function normalizeRequest()
{
// normalize request
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
if(isset($_GET))
$_GET=$this->stripSlashes($_GET);
if(isset($_POST))
$_POST=$this->stripSlashes($_POST);
if(isset($_REQUEST))
$_REQUEST=$this->stripSlashes($_REQUEST);
if(isset($_COOKIE))
$_COOKIE=$this->stripSlashes($_COOKIE);
}
if($this->enableCsrfValidation)
...
}
I’m doing something stupid but I can’t see what it is…how do I do it?