3 namespace Friendica\Module\Admin;
5 use Friendica\Core\Renderer;
6 use Friendica\Database\DBA;
8 use Friendica\Module\BaseAdmin;
9 use Friendica\Util\Arrays;
10 use Friendica\Util\DateTimeFormat;
13 * 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 BaseAdmin
22 public static function content(array $parameters = [])
24 parent::content($parameters);
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 `retrial` > ?", 0];
34 $sub_title = DI::l10n()->t('Inspect Deferred Worker Queue');
35 $info = DI::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 `retrial` = ?", 0];
38 $sub_title = DI::l10n()->t('Inspect Worker Queue');
39 $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.');
42 // @TODO Move to Model\WorkerQueue::getEntries()
43 $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['limit' => 999, 'order' => ['created']]);
46 while ($entry = DBA::fetch($entries)) {
47 // fix GH-5469. ref: src/Core/Worker.php:217
48 $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
49 $entry['created'] = DateTimeFormat::local($entry['created']);
54 $t = Renderer::getMarkupTemplate('admin/queue.tpl');
55 return Renderer::replaceMacros($t, [
56 '$title' => DI::l10n()->t('Administration'),
57 '$page' => $sub_title,
58 '$count' => count($r),
59 '$id_header' => DI::l10n()->t('ID'),
60 '$param_header' => DI::l10n()->t('Job Parameters'),
61 '$created_header' => DI::l10n()->t('Created'),
62 '$prio_header' => DI::l10n()->t('Priority'),