+/**
+ * @brief Admin Inspect Worker Queue Page
+ *
+ * Generates a page for the admin to have a look into the current queue of
+ * worker jobs. Shown are the parameters for the job and its priority.
+ *
+ * The returned string holds the content of the page.
+ *
+ * @param App $a
+ * @return string
+ */
+function admin_page_workerqueue(App $a)
+{
+ // get jobs from the workerqueue table
+ $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
+
+ $r = [];
+ while ($entry = DBA::fetch($entries)) {
+ // fix GH-5469. ref: src/Core/Worker.php:217
+ $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
+ $entry['created'] = DateTimeFormat::local($entry['created']);
+ $r[] = $entry;
+ }
+ DBA::close($entries);
+
+ $t = get_markup_template('admin/workerqueue.tpl');
+ return replace_macros($t, [
+ '$title' => L10n::t('Administration'),
+ '$page' => L10n::t('Inspect Worker Queue'),
+ '$count' => count($r),
+ '$id_header' => L10n::t('ID'),
+ '$param_header' => L10n::t('Job Parameters'),
+ '$created_header' => L10n::t('Created'),
+ '$prio_header' => L10n::t('Priority'),
+ '$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.'),
+ '$entries' => $r,
+ ]);
+}
+