]> git.mxchange.org Git - friendica.git/commitdiff
Adjusted implementation to a better one (thanks to Michael Vogel)
authorUnknown <me@jeroened.be>
Tue, 7 Aug 2018 08:18:59 +0000 (10:18 +0200)
committerUnknown <me@jeroened.be>
Tue, 7 Aug 2018 08:18:59 +0000 (10:18 +0200)
mod/admin.php

index 9be75f6f90d79057c5fade43369392f3687a9b32..153b105063950614f7fbf9161081d5bb86268639 100644 (file)
@@ -746,25 +746,19 @@ function admin_page_federation(App $a)
 function admin_page_queue(App $a)
 {
        // get content from the queue table
-       /*
-       //todo: convert q() to DBA::Select()
-       $statement = DBA::Select('`queue` AS `q`, `contact` AS `c`',
-               [ '`c`.`name`', '`c`.`nurl`', '`q`.`id`', '`q`.`network`', "CONVERT_TZ(`q`.`created`, 'UTC' " . Config::get('system', 'default_timezone') . ') as created', "CONVERT_TZ(`q`.`last`, 'UTC', " . Config::get('system', 'default_timezone') . "') as last" ],
-               '`c`.`id`' => '`q`.`cid`',
-               ['order'=> ['`q`.`cid`, `q`.`created`']]
-       );
-       $r = DBA::toArray($statement);
-       */
-       
-       $r = q("SELECT `c`.`name`, `c`.`nurl`, `q`.`id`, `q`.`network`, `q`.`created`, `q`.`last`
-                       FROM `queue` AS `q`, `contact` AS `c`
-                       WHERE `c`.`id` = `q`.`cid`
-                       ORDER BY `q`.`cid`, `q`.`created`;");
+       $entries = DBA::p("SELECT `contact`.`name`, `contact`.`nurl`,
+                `queue`.`id`, `queue`.`network`, `queue`.`created`, `queue`.`last`
+                FROM `queue` INNER JOIN `contact` ON `contact`.`id` = `queue`.`cid`
+                ORDER BY `queue`.`cid`, `queue`.`created`");
 
-       foreach ($r as $key => $rr) {
-               $r[$key]['created'] = DateTimeFormat::local($rr['created']);
-               $r[$key]['last'] = DateTimeFormat::local($rr['last']);
+       $r = [];
+       while ($entry = DBA::fetch($entries)) {
+               $entry['created'] = DateTimeFormat::local($entry['created']);
+               $entry['last'] = DateTimeFormat::local($entry['last']);
+               $r[] = $entry;
        }
+       DBA::close($entries);
+
        $t = get_markup_template('admin/queue.tpl');
        return replace_macros($t, [
                '$title' => L10n::t('Administration'),
@@ -795,13 +789,15 @@ function admin_page_queue(App $a)
 function admin_page_workerqueue(App $a)
 {
        // get jobs from the workerqueue table
-       $statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
+       $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
        $r = DBA::toArray($statement);
 
-       foreach ($r as $key => $rr) {
+       $r = [];
+       while ($entry = DBA::fetch($entries)) {
                // fix GH-5469. ref: src/Core/Worker.php:217
-               $r[$key]['parameter'] = Arrays::recursiveImplode(json_decode($rr['parameter'], true), ': ');
-               $r[$key]['created'] = DateTimeFormat::local($rr['created']);
+               $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
+               $entry['created'] = DateTimeFormat::local($entry['created']);
+               $r[] = $entry;
        }
 
        $t = get_markup_template('admin/workerqueue.tpl');