问题
As stated, when I use in a shell :
$this->requestAction('/sites/zaz/option1');
The action doesn't get triggered. To test this, I tried :
public function zaz($option1 = null) {
CakeLog::write('acces', 'action triggered');
return 'got it !';
}
And the action isn't done and there is no log written whatsoever. All my other logs do work.
So I tried :
$this->requestAction('/sites/actionwhichdoesntexist/option1');
And I got an error stating that the action doesn't exist.
I really need to use requestAction, because I have a model/controller and this action is typically testing that a ressource is still alive. I want to use requestAction in order to smoothly handle the "requested" aspect, so that I will build something more robust :
if(empty($this->request->params['requested']))
$this->redirect(array('controller'=>'proxies', 'action'=>'index', 'admin'=>true));
else
return true;
I tried with 2.4.1 and 2.5, nothing just happens, no output is given, even if I put a 'die()' in the action.
回答1:
As stated in the first comment, I should have checked the beforeFilter function.
来源:https://stackoverflow.com/questions/24112370/cant-use-requestaction-from-shell-in-cakephp-2-5