diff --git a/mod/admin.php b/mod/admin.php index e77780c086..7f2077bead 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -228,12 +228,6 @@ function admin_content(App $a) case 'dbsync': $o = admin_page_dbsync($a); break; - case 'deferred': - $o = admin_page_workerqueue($a, true); - break; - case 'workerqueue': - $o = admin_page_workerqueue($a, false); - break; case 'deleteitem': $o = admin_page_deleteitem($a); break; @@ -311,57 +305,6 @@ function admin_page_deleteitem_post(App $a) return; // NOTREACHED } -/** - * @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 - * @param $deferred - * @return string - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ -function admin_page_workerqueue(App $a, $deferred) -{ - // get jobs from the workerqueue table - if ($deferred) { - $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()]; - $sub_title = L10n::t('Inspect Deferred Worker Queue'); - $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time."); - } else { - $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()]; - $sub_title = L10n::t('Inspect Worker Queue'); - $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 = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['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 = Renderer::getMarkupTemplate('admin/workerqueue.tpl'); - return Renderer::replaceMacros($t, [ - '$title' => L10n::t('Administration'), - '$page' => $sub_title, - '$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' => $info, - '$entries' => $r, - ]); -} - /** * @brief Process send data from Admin Site Page * diff --git a/src/App/Router.php b/src/App/Router.php index 1cf19c53d6..0fbb78b8bc 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -130,6 +130,8 @@ class Router $collector->addRoute(['GET', 'POST'], '/features' , Module\Admin\Features::class); $collector->addRoute(['GET'] , '/federation' , Module\Admin\Federation::class); + $collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class); + $collector->addRoute(['GET', 'POST'], '/themes' , Module\Admin\Themes\Index::class); $collector->addRoute(['GET', 'POST'], '/tos' , Module\Admin\Tos::class); diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php new file mode 100644 index 0000000000..705529166c --- /dev/null +++ b/src/Module/Admin/Queue.php @@ -0,0 +1,66 @@ +argc > 2 && $a->argv[2] == 'deferred'; + + // get jobs from the workerqueue table + if ($deferred) { + $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()]; + $sub_title = L10n::t('Inspect Deferred Worker Queue'); + $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time."); + } else { + $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()]; + $sub_title = L10n::t('Inspect Worker Queue'); + $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 = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['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 = Renderer::getMarkupTemplate('admin/queue.tpl'); + return Renderer::replaceMacros($t, [ + '$title' => L10n::t('Administration'), + '$page' => $sub_title, + '$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' => $info, + '$entries' => $r, + ]); + } +} diff --git a/src/Module/BaseAdminModule.php b/src/Module/BaseAdminModule.php index bc84ad8873..c31ce8ca06 100644 --- a/src/Module/BaseAdminModule.php +++ b/src/Module/BaseAdminModule.php @@ -59,6 +59,10 @@ abstract class BaseAdminModule extends BaseModule 'features' => ['admin/features' , L10n::t('Additional features') , 'features'], 'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'], ]], + 'database' => [L10n::t('Database'), [ + 'deferred' => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'], + 'workerqueue' => ['admin/queue' , L10n::t('Inspect worker Queue') , 'workerqueue'], + ]], 'tools' => [L10n::t('Tools'), [ 'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'], 'blocklist' => ['admin/blocklist/server' , L10n::t('Server Blocklist') , 'blocklist'], diff --git a/view/templates/admin/queue.tpl b/view/templates/admin/queue.tpl index aaca9b0148..5bab58a5e9 100644 --- a/view/templates/admin/queue.tpl +++ b/view/templates/admin/queue.tpl @@ -5,20 +5,16 @@ - - - + - + {{foreach $entries as $e}} - - - + - + {{/foreach}}
{{$id_header}}{{$to_header}}{{$url_header}}{{$network_header}}{{$param_header}} {{$created_header}}{{$last_header}}{{$prio_header}}
{{$e.id}}{{$e.name}}{{$e.nurl}}{{$e.network}}{{$e.parameter}} {{$e.created}}{{$e.last}}{{$e.priority}}
diff --git a/view/templates/admin/summary.tpl b/view/templates/admin/summary.tpl index 7b655a8ecc..121eb833b9 100644 --- a/view/templates/admin/summary.tpl +++ b/view/templates/admin/summary.tpl @@ -11,7 +11,7 @@
{{$queues.label}}
-
{{$queues.deferred}} - {{$queues.workerq}}
+
{{$queues.deferred}} - {{$queues.workerq}}
{{$pending.0}}
diff --git a/view/templates/admin/workerqueue.tpl b/view/templates/admin/workerqueue.tpl deleted file mode 100644 index 5bab58a5e9..0000000000 --- a/view/templates/admin/workerqueue.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
-

{{$title}} - {{$page}} ({{$count}})

- -

{{$info}}

- - - - - - - - {{foreach $entries as $e}} - - - - - - - {{/foreach}} -
{{$id_header}}{{$param_header}}{{$created_header}}{{$prio_header}}
{{$e.id}}{{$e.parameter}}{{$e.created}}{{$e.priority}}
-
diff --git a/view/theme/frio/templates/admin/queue.tpl b/view/theme/frio/templates/admin/queue.tpl index dde3863999..ab076a0f73 100644 --- a/view/theme/frio/templates/admin/queue.tpl +++ b/view/theme/frio/templates/admin/queue.tpl @@ -5,20 +5,16 @@ - - - + - + {{foreach $entries as $e}} - - - + - + {{/foreach}}
{{$id_header}}{{$to_header}}{{$url_header}}{{$network_header}}{{$param_header}} {{$created_header}}{{$last_header}}{{$prio_header}}
{{$e.id}}{{$e.name}}{{$e.nurl}}{{$e.network}}{{$e.parameter}} {{$e.created}}{{$e.last}}{{$e.priority}}
diff --git a/view/theme/frio/templates/admin/summary.tpl b/view/theme/frio/templates/admin/summary.tpl index 9dbd3f7e6b..0fd599b051 100644 --- a/view/theme/frio/templates/admin/summary.tpl +++ b/view/theme/frio/templates/admin/summary.tpl @@ -14,7 +14,7 @@ {{* The work queues short statistic. *}}
{{$queues.label}}
-
{{$queues.deferred}} - {{$queues.workerq}}
+
{{$queues.deferred}} - {{$queues.workerq}}
{{* Number of pending registrations. *}} diff --git a/view/theme/frio/templates/admin/workerqueue.tpl b/view/theme/frio/templates/admin/workerqueue.tpl deleted file mode 100644 index ab076a0f73..0000000000 --- a/view/theme/frio/templates/admin/workerqueue.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
-

{{$title}} - {{$page}} ({{$count}})

- -

{{$info}}

- - - - - - - - {{foreach $entries as $e}} - - - - - - - {{/foreach}} -
{{$id_header}}{{$param_header}}{{$created_header}}{{$prio_header}}
{{$e.id}}{{$e.parameter}}{{$e.created}}{{$e.priority}}
-