From: Unknown Date: Tue, 7 Aug 2018 08:18:59 +0000 (+0200) Subject: Adjusted implementation to a better one (thanks to Michael Vogel) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c254ee401ed5cc77d11648d1e2c6e9223188e99;p=friendica.git Adjusted implementation to a better one (thanks to Michael Vogel) --- diff --git a/mod/admin.php b/mod/admin.php index 9be75f6f90..153b105063 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -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');