3 namespace Friendica\Module\Admin;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Database\DBA;
8 use Friendica\Module\BaseAdminModule;
9 use Friendica\Util\Arrays;
10 use Friendica\Util\DateTimeFormat;
13 * @brief Admin Inspect Queue Page
15 * Generates a page for the admin to have a look into the current queue of
16 * worker jobs. Shown are the parameters for the job and its priority.
20 class Queue extends BaseAdminModule
22 public static function content()
28 // @TODO: Replace with parameter from router
29 $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';
31 // get jobs from the workerqueue table
33 $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];
34 $sub_title = L10n::t('Inspect Deferred Worker Queue');
35 $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");
37 $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
38 $sub_title = L10n::t('Inspect Worker Queue');
39 $info = L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.');
42 $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order' => ['priority']]);
45 while ($entry = DBA::fetch($entries)) {
46 // fix GH-5469. ref: src/Core/Worker.php:217
47 $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
48 $entry['created'] = DateTimeFormat::local($entry['created']);
53 $t = Renderer::getMarkupTemplate('admin/queue.tpl');
54 return Renderer::replaceMacros($t, [
55 '$title' => L10n::t('Administration'),
56 '$page' => $sub_title,
57 '$count' => count($r),
58 '$id_header' => L10n::t('ID'),
59 '$param_header' => L10n::t('Job Parameters'),
60 '$created_header' => L10n::t('Created'),
61 '$prio_header' => L10n::t('Priority'),