]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Queue.php
Merge pull request #7435 from annando/select-to-array
[friendica.git] / src / Module / Admin / Queue.php
index 705529166cf32f2d679c3dfc6dcda40359589ad2..e89aa53c620e4e65e789ae1baaea6c6ad215581e 100644 (file)
@@ -1,66 +1,67 @@
-<?php\r
-\r
-namespace Friendica\Module\Admin;\r
-\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\Renderer;\r
-use Friendica\Database\DBA;\r
-use Friendica\Module\BaseAdminModule;\r
-use Friendica\Util\Arrays;\r
-use Friendica\Util\DateTimeFormat;\r
-\r
-/**\r
- * @brief Admin Inspect Queue Page\r
- *\r
- * Generates a page for the admin to have a look into the current queue of\r
- * worker jobs. Shown are the parameters for the job and its priority.\r
- *\r
- * @return string\r
- */\r
-class Queue extends BaseAdminModule\r
-{\r
-       public static function content()\r
-       {\r
-               parent::content();\r
-\r
-               $a = self::getApp();\r
-\r
-               // @TODO: Replace with parameter from router\r
-               $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';\r
-\r
-               // get jobs from the workerqueue table\r
-               if ($deferred) {\r
-                       $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];\r
-                       $sub_title = L10n::t('Inspect Deferred Worker Queue');\r
-                       $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");\r
-               } else {\r
-                       $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];\r
-                       $sub_title = L10n::t('Inspect Worker Queue');\r
-                       $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.');\r
-               }\r
-\r
-               $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order' => ['priority']]);\r
-\r
-               $r = [];\r
-               while ($entry = DBA::fetch($entries)) {\r
-                       // fix GH-5469. ref: src/Core/Worker.php:217\r
-                       $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');\r
-                       $entry['created'] = DateTimeFormat::local($entry['created']);\r
-                       $r[] = $entry;\r
-               }\r
-               DBA::close($entries);\r
-\r
-               $t = Renderer::getMarkupTemplate('admin/queue.tpl');\r
-               return Renderer::replaceMacros($t, [\r
-                       '$title' => L10n::t('Administration'),\r
-                       '$page' => $sub_title,\r
-                       '$count' => count($r),\r
-                       '$id_header' => L10n::t('ID'),\r
-                       '$param_header' => L10n::t('Job Parameters'),\r
-                       '$created_header' => L10n::t('Created'),\r
-                       '$prio_header' => L10n::t('Priority'),\r
-                       '$info' => $info,\r
-                       '$entries' => $r,\r
-               ]);\r
-       }\r
-}\r
+<?php
+
+namespace Friendica\Module\Admin;
+
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Database\DBA;
+use Friendica\Module\BaseAdminModule;
+use Friendica\Util\Arrays;
+use Friendica\Util\DateTimeFormat;
+
+/**
+ * @brief Admin Inspect 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.
+ *
+ * @return string
+ */
+class Queue extends BaseAdminModule
+{
+       public static function content()
+       {
+               parent::content();
+
+               $a = self::getApp();
+
+               // @TODO: Replace with parameter from router
+               $deferred = $a->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.');
+               }
+
+               // @TODO Move to Model\WorkerQueue::getEntries()
+               $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,
+               ]);
+       }
+}