3 namespace Friendica\Module\Admin;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Database\DBA;
9 use Friendica\Module\BaseAdminModule;
10 use Friendica\Util\Arrays;
11 use Friendica\Util\DateTimeFormat;
14 * Admin Inspect Queue Page
16 * Generates a page for the admin to have a look into the current queue of
17 * worker jobs. Shown are the parameters for the job and its priority.
21 class Queue extends BaseAdminModule
23 public static function content(array $parameters = [])
25 parent::content($parameters);
29 // @TODO: Replace with parameter from router
30 $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';
32 // get jobs from the workerqueue table
34 $condition = ["NOT `done` AND `retrial` > ?", 0];
35 $sub_title = DI::l10n()->t('Inspect Deferred Worker Queue');
36 $info = DI::l10n()->t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");
38 $condition = ["NOT `done` AND `retrial` = ?", 0];
39 $sub_title = DI::l10n()->t('Inspect Worker Queue');
40 $info = DI::l10n()->t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.');
43 // @TODO Move to Model\WorkerQueue::getEntries()
44 $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['limit' => 999, 'order' => ['created']]);
47 while ($entry = DBA::fetch($entries)) {
48 // fix GH-5469. ref: src/Core/Worker.php:217
49 $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
50 $entry['created'] = DateTimeFormat::local($entry['created']);
55 $t = Renderer::getMarkupTemplate('admin/queue.tpl');
56 return Renderer::replaceMacros($t, [
57 '$title' => DI::l10n()->t('Administration'),
58 '$page' => $sub_title,
59 '$count' => count($r),
60 '$id_header' => DI::l10n()->t('ID'),
61 '$param_header' => DI::l10n()->t('Job Parameters'),
62 '$created_header' => DI::l10n()->t('Created'),
63 '$prio_header' => DI::l10n()->t('Priority'),