Can't use requestAction from Shell in Cakephp 2.5

≯℡__Kan透↙ 提交于 2021-02-11 07:58:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!