Jobs - "executeJob" vs "run"
Permalink
Just a gottcha which caught me out. Putting it here for anyone else.
The "run" method doesn't update the Job database table in any way whatsoever. So the job will run, but you wont get any updates to "jobLastRun" dates.
"executeJob" is the more robust method that behaves as you'd expect.
The "run" method doesn't update the Job database table in any way whatsoever. So the job will run, but you wont get any updates to "jobLastRun" dates.
"executeJob" is the more robust method that behaves as you'd expect.
Not sure I'm with you. run() most definitely isn't updating the job status for me.
It most definitely does for me ;-)
Have you checked the code I've mentioned above? If you override executeJob, you'll also override the code which marks a job as executed. You can also see that the run() method is specified as "abstract", not implementing it would certainly be wrong..
Have you checked the code I've mentioned above? If you override executeJob, you'll also override the code which marks a job as executed. You can also see that the run() method is specified as "abstract", not implementing it would certainly be wrong..
I'm doing this;
Which, as far I can tell, does exactly what I'd expect (and is what I see in the function).
- Mark the Job as running
- Try to run the job
- If it completes, mark as Completed.
If I do this;
... I get zero updates to the Jobs database table. Nothing. But the job runs.
Loader::model("job"); $fetch_feed = Job::getByHandle('fetch_feed'); $fetch_feed->executeJob();
Which, as far I can tell, does exactly what I'd expect (and is what I see in the function).
- Mark the Job as running
- Try to run the job
- If it completes, mark as Completed.
If I do this;
Loader::model("job"); $fetch_feed = Job::getByHandle('fetch_feed'); $fetch_feed->run();
... I get zero updates to the Jobs database table. Nothing. But the job runs.
Ah okay, now I get what you mean!
When you call the job yourself, you'll have to call "executeJob", but when you implement a job, you'll have to use the "run" method.
I think it's pretty rare that someone calls a job directly, but if they do, executeJob is the way to go
When you call the job yourself, you'll have to call "executeJob", but when you implement a job, you'll have to use the "run" method.
I think it's pretty rare that someone calls a job directly, but if they do, executeJob is the way to go
https://github.com/concrete5/concrete5/blob/master/web/concrete/core...