【发布时间】:2020-10-08 03:16:29
【问题描述】:
我正在尝试制作一个 cron shell,为此使用 requestAction 的能力至关重要。
出于测试目的,我已将我的 Shell 缩减为:
class CronShell extends AppShell {
public $uses = array('Cron');
public function main() {
$this->requestAction(['controller' => 'events', 'action' => 'play', 38, 0, true, true]);
echo "This will never be printed to the console, it dies before this.";
}
}
我仍然无法让它运行。它只是简单地返回表面上成功,但实际上并非如此。 (没有错误)Another SO question 建议的 beforeFilter(和其他生命周期方法)可能是原因,但 我已确保不是这种情况。 查看更新。
- 其他控制器/操作不起作用。
- 删除操作的
return没有帮助。 - 使用基于字符串的调用没有帮助。
- CakePHP v2.10.22
更新:看起来 Auth 组件可能会导致重定向到 AppController 中的 users/login。然而,我看不到我告诉它重定向到这里的地方,而且我什至没有有 users/login 操作。当我从public $components = [] 中删除'Auth' 时,shell 会在 CLI 上运行。
但我无法禁用 Auth!我试过允许(*),将重定向设置为 false,甚至尝试$this->components = ['']。我总是被重定向到用户/登录。
【问题讨论】:
标签: cakephp cakephp-2.0