-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Reset job disabling timer on adding the job again #30358
Conversation
60c3f15
to
28a7373
Compare
Can we prevent duplicate code? But maybe I missed some tiny difference :). public function add($job, $argument = null) {
if ($job instanceof IJob) {
$class = get_class($job);
} else {
$class = $job;
}
$argument = json_encode($argument);
if (strlen($argument) > 4000) {
throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)');
}
$query = $this->connection->getQueryBuilder();
if (!$this->has($job, $argument)) {
$query->insert('jobs')
->values([
'class' => $query->createNamedParameter($class),
'argument' => $query->createNamedParameter($argument),
'last_run' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
'last_checked' => $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT),
]);
} else {
$query->update('jobs')
->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
->set('last_checked', $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('class', $query->createNamedParameter($class)))
->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument)));
}
$query->execute();
} |
@artonge Pushed a fixup with some minor adjustment because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move $query->execute();
out of the if
, but ok for me :)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
221d0e6
to
b30193e
Compare
Rebased, squashed, replaced deprecated execute with executeStatement and moved it out of the if as well ;) |
/backport to stable23 |
/backport to stable22 |
/backport to stable21 |
If a job run is triggered while having the app disabled the next execution will be delayed for 12 hours
server/lib/private/BackgroundJob/JobList.php
Lines 235 to 241 in 60c3f15
This PR ensures that the job is rescheduled immediately if an app gets enabled and the jobs from appinfo.xml get parsed again in
server/lib/private/Installer.php
Line 160 in 37f40cd
Fixes #30285