-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.php
60 lines (51 loc) · 1.36 KB
/
job.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
ignore_user_abort(true);
$dir = __DIR__;
require($dir . '/src/XF.php');
XF::start($dir);
$app = XF::setupApp('XF\Pub\App');
$output = ['more' => false];
if (\XF::$versionId == $app->options()->currentVersionId || !$app->config('checkVersion'))
{
$jobManager = $app->jobManager();
$maxRunTime = $app->config('jobMaxRunTime');
$onlyIds = $app->request()->filter('only_ids', 'array-uint');
if ($onlyIds)
{
$multiResult = $jobManager->runByIds($onlyIds, $maxRunTime);
if ($multiResult['remaining'])
{
$output['more'] = true;
/** @var \XF\Job\JobResult $jobResult */
$jobResult = $multiResult['result'];
if ($jobResult)
{
$output['status'] = $jobResult->statusMessage;
}
$output['ids'] = $multiResult['remaining'];
}
else
{
$output['moreAuto'] = $jobManager->queuePending(false);
}
}
else
{
$jobResult = $jobManager->runQueue(false, $maxRunTime);
if ($jobResult)
{
$output['more'] = $jobManager->queuePending(false);
}
}
}
else
{
$output['skipped'] = true;
}
header('Content-Type: application/json; charset=UTF-8');
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo json_encode($output);