X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FQueue.php;h=355433492ca074b5965fec72c78921b5855f9fba;hb=5ea033db33c62562dcd27dd70447a35b3d14326e;hp=8e9ed40d031003b550b324b052db9b4549b6b5a7;hpb=4e44b07dfe07dde78fe8a095fbb43d9ec1ffcb53;p=friendica.git diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 8e9ed40d03..355433492c 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -5,22 +5,21 @@ namespace Friendica\Model; use Friendica\Core\Config; -use Friendica\Database\dba; -use Friendica\Database\DBM; +use Friendica\Core\Logger; +use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - class Queue { /** * @param string $id id + * @throws \Exception */ public static function updateTime($id) { - logger('queue: requeue item ' . $id); - $queue = dba::selectFirst('queue', ['retrial'], ['id' => $id]); - if (!DBM::is_result($queue)) { + Logger::log('queue: requeue item ' . $id); + $queue = DBA::selectFirst('queue', ['retrial'], ['id' => $id]); + if (!DBA::isResult($queue)) { return; } @@ -34,16 +33,17 @@ class Queue $delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1)); $next = DateTimeFormat::utc('now + ' . $delay . ' seconds'); - dba::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]); + DBA::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]); } /** * @param string $id id + * @throws \Exception */ public static function removeItem($id) { - logger('queue: remove queue item ' . $id); - dba::delete('queue', ['id' => $id]); + Logger::log('queue: remove queue item ' . $id); + DBA::delete('queue', ['id' => $id]); } /** @@ -52,6 +52,7 @@ class Queue * @param int $cid Contact id * * @return bool The communication with this contact has currently problems + * @throws \Exception */ public static function wasDelayed($cid) { @@ -61,7 +62,7 @@ class Queue intval($cid) ); - $was_delayed = DBM::is_result($r); + $was_delayed = DBA::isResult($r); // We set "term-date" to a current date if the communication has problems. // If the communication works again we reset this value. @@ -69,7 +70,7 @@ class Queue $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` <= '1000-01-01' LIMIT 1", intval($cid) ); - $was_delayed = !DBM::is_result($r); + $was_delayed = !DBA::isResult($r); } return $was_delayed; @@ -80,6 +81,8 @@ class Queue * @param string $network network * @param string $msg message * @param boolean $batch batch, default false + * @param string $guid + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function add($cid, $network, $msg, $batch = false, $guid = '') { @@ -99,17 +102,17 @@ class Queue intval($cid) ); - if (DBM::is_result($r)) { + if (DBA::isResult($r)) { if ($batch && ($r[0]['total'] > $batch_queue)) { - logger('too many queued items for batch server ' . $cid . ' - discarding message'); + Logger::log('too many queued items for batch server ' . $cid . ' - discarding message'); return; } elseif ((! $batch) && ($r[0]['total'] > $max_queue)) { - logger('too many queued items for contact ' . $cid . ' - discarding message'); + Logger::log('too many queued items for contact ' . $cid . ' - discarding message'); return; } } - dba::insert('queue', [ + DBA::insert('queue', [ 'cid' => $cid, 'network' => $network, 'guid' => $guid, @@ -118,6 +121,6 @@ class Queue 'content' => $msg, 'batch' =>($batch) ? 1 : 0 ]); - logger('Added item ' . $guid . ' for ' . $cid); + Logger::log('Added item ' . $guid . ' for ' . $cid); } }