[TYPO3-dev] Scheduler and Saving Task State
Francois Suter
fsu-lists at cobweb.ch
Fri Apr 23 09:09:08 CEST 2010
Hi Jeff,
> This appears to be due to tx_scheduler->executeTask() which runs
> $task->save() prior to $task->execute. Is this the intended behavior? If
> so, I guess the best option is to just write my data somewhere else for
> saving rather than expecting my task to be persistent.
The task is saved prior to actual execution because that triggers the
calculation of the next execution date. Looking at this in retrospect
doesn't make it look very clever. We would probably need 2 different
methods: one that just saves the task and one that calculates next
execution time and saves. That's a bit too late to have such a change in
4.4, but you may want to open a bug tracker issue so that we don't forget.
About your current problem, I can see two solutions:
1) set the values to remember in some member variables of your task and
call $this->save(). The risk you run is that a new time of next
execution may be calculated if the task has run a long time and is
already beyond the next execution time calculated during the first call
to tx_scheduler::saveTask().
2) store the values that you need to recover in the new system registry.
This is very easy and is documented in the latest version of Core APIs.
The Scheduler does this itself to save information about its latest run.
HTH
--
Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
More information about the TYPO3-dev
mailing list