-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tasks are not executed as tasks! #18
Comments
Sorry for the delay. I agree, this looks like it would be an improvement over how tasks are currently loaded and executed. When I get an opportunity I will try to update this (next two holiday weeks will fill up my schedule). If anyone has experience with the the taskregistry with 3.0 and can send a pull request that would be great too. |
I looked back over this and currently doing deeper thinking on how to re-work this to be a little more future-proof. Currently the plugin does use the TaskRegistry to load the task. https://github.com/trentrichardson/cakephp-scheduler/blob/master/src/Shell/SchedulerShell.php#L211 However as you mention there could be some issue with The dispatchShell method appears to be geared for calling Shells, not Tasks as SchedulerShell does. Technically Tasks extend Shell, so they are shells, but I don't know that this method was intended to call Tasks directly, and could cause issue down the road? |
might be useful to discuss with the CakePHP community? |
@half2me I added some tests in the cakephp-v3.0 branch and was able to replicate this issue. I will look deeper into using dispatchShell over the next couple nights. If you get an opportunity as well look at the cakephp-v3.0 branch as that is where the latest code is. |
@trentrichardson alrighty |
Tasks are executed with
call_user_func_array
this means that the main() method of the task will be executed without any support for the CakePHP framework, just plain PHP.Here is my example:
The initialize function is never called, so the Model data cannot be accessed.
When running the task, we get the following error:
Instead we should use load tasks with TaskRegsitry
(http://book.cakephp.org/3.0/en/console-and-shells.html#loading-tasks-on-the-fly-with-taskregistry)
Arguements can be passed as well since 3.1
(http://book.cakephp.org/3.0/en/console-and-shells.html#passing-extra-parameters-to-the-dispatched-shell)
The text was updated successfully, but these errors were encountered: