]> git.mxchange.org Git - friendica.git/commitdiff
Old database functions had been replaced in the workers
authorMichael <heluecht@pirati.ca>
Mon, 9 Apr 2018 21:34:23 +0000 (21:34 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 9 Apr 2018 21:34:23 +0000 (21:34 +0000)
src/Worker/Delivery.php
src/Worker/DiscoverPoCo.php
src/Worker/Notifier.php
src/Worker/PubSubPublish.php
src/Worker/Queue.php
src/Worker/TagUpdate.php

index 523bde4dbe71306407d0e07b3c285e82635c989f..88085357af0fb96f5cb0cd0652ccd6769c81b52f 100644 (file)
@@ -208,7 +208,7 @@ class Delivery {
                                        $atom = DFRN::mail($item, $owner);
                                } elseif ($fsuggest) {
                                        $atom = DFRN::fsuggest($item, $owner);
-                                       q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
+                                       dba::delete('fsuggest', ['id' => $item['id']]);
                                } elseif ($relocate) {
                                        $atom = DFRN::relocate($owner, $uid);
                                } elseif ($followup) {
@@ -290,9 +290,7 @@ class Delivery {
                                        if ($x && count($x)) {
                                                $write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
                                                if ((($owner['page-flags'] == PAGE_COMMUNITY) || $write_flag) && !$x[0]['writable']) {
-                                                       q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d",
-                                                               intval($x[0]['id'])
-                                                       );
+                                                       dba::update('contact', ['writable' => true], ['id' => $x[0]['id']]);
                                                        $x[0]['writable'] = 1;
                                                }
 
index a82fa12087ac9459bcc72c8cb4aba643a5663a3a..f0335bc8e443334aa0ac5866775219d812825cb8 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
+use dba;
 
 class DiscoverPoCo {
        /// @todo Clean up this mess of a parameter hell and split it in several classes
@@ -158,8 +159,8 @@ class DiscoverPoCo {
 
                        $urlparts = parse_url($user["url"]);
                        if (!isset($urlparts["scheme"])) {
-                               q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
-                                       dbesc(NETWORK_PHANTOM), dbesc(normalise_link($user["url"])));
+                               dba::update('gcontact', ['network' => NETWORK_PHANTOM],
+                                       ['nurl' => normalise_link($user["url"])]);
                                continue;
                         }
 
@@ -171,8 +172,8 @@ class DiscoverPoCo {
                                                "identi.ca" => NETWORK_PUMPIO,
                                                "alpha.app.net" => NETWORK_APPNET];
 
-                               q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
-                                       dbesc($networks[$urlparts["host"]]), dbesc(normalise_link($user["url"])));
+                               dba::update('gcontact', ['network' => $networks[$urlparts["host"]]],
+                                       ['nurl' => normalise_link($user["url"])]);
                                continue;
                        }
 
@@ -194,8 +195,8 @@ class DiscoverPoCo {
                                        return;
                                }
                        } else {
-                               q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
-                                       dbesc(DateTimeFormat::utcNow()), dbesc(normalise_link($user["url"])));
+                               dba::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
+                                       ['nurl' => normalise_link($user["url"])]);
                        }
 
                        // Quit the loop after 3 minutes
index 49fd5e3187bc56900e6ca603a557425df594403d..e4e72023616bf28d4c4b1e2d7bfb5017ec12ae2e 100644 (file)
@@ -541,8 +541,8 @@ class Notifier {
                if ($push_notify) {
                        // Set push flag for PuSH subscribers to this topic,
                        // they will be notified in queue.php
-                       q("UPDATE `push_subscriber` SET `push` = 1 ".
-                         "WHERE `nickname` = '%s' AND `push` = 0", dbesc($owner['nickname']));
+                       $condition = ['push' => false, 'nickname' => $owner['nickname']];
+                       dba::update('push_subscriber', ['push' => true], $condition);
 
                        logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
 
index 03608bea66d540c8a3376fca791fd533b1d52a1c..de26eab9c14cee66e9219466c9a5eb42ee2e18f3 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\Network;
+use dba;
 
 require_once 'include/items.php';
 
@@ -76,9 +77,8 @@ class PubSubPublish {
                        logger('successfully pushed to '.$rr['callback_url']);
 
                        // set last_update to the "created" date of the last item, and reset push=0
-                       q("UPDATE `push_subscriber` SET `push` = 0, last_update = '%s' WHERE id = %d",
-                               dbesc($last_update),
-                               intval($rr['id']));
+                       $fields = ['push' => 0, 'last_update' => $last_update];
+                       dba::update('push_subscriber', $fields, ['id' => $rr['id']]);
 
                } else {
                        logger('error when pushing to '.$rr['callback_url'].' HTTP: '.$ret);
@@ -90,9 +90,7 @@ class PubSubPublish {
                        if ($new_push > 30) // OK, let's give up
                                $new_push = 0;
 
-                       q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d",
-                               $new_push,
-                               intval($rr['id']));
+                       dba::update('push_subscriber', ['push' => $new_push], ['id' => $rr['id']]);
                }
        }
 }
index 46f6faf95d31334561ec54061bf88cca172bc6ef..5c8942db2ae039230d4858bf4e683185327337e5 100644 (file)
@@ -36,7 +36,7 @@ class Queue
                        // Handling the pubsubhubbub requests
                        Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'PubSubPublish');
 
-                       $r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP()"));
+                       $r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
 
                        Addon::callHooks('queue_predeliver', $r);
 
index fa3079731c7eb5d88907b4046263b2ba244a4a7e..f6a141ad6d543eef8d1aa605c7e42148c9f53acd 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Friendica\Worker;
 
+use dba;
+
 class TagUpdate
 {
        public static function execute()
@@ -13,18 +15,14 @@ class TagUpdate
                        if ($message['uid'] == 0) {
                                $global = true;
 
-                               q("UPDATE `term` SET `global` = 1 WHERE `otype` = %d AND `guid` = '%s'",
-                                       intval(TERM_OBJ_POST), dbesc($message['guid']));
+                               dba::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
                        } else {
-                               $isglobal = q("SELECT `global` FROM `term` WHERE `uid` = 0 AND `otype` = %d AND `guid` = '%s'",
-                                       intval(TERM_OBJ_POST), dbesc($message['guid']));
-
-                               $global = (count($isglobal) > 0);
+                               $global = (dba::count('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]) > 0);
                        }
 
-                       q("UPDATE `term` SET `guid` = '%s', `created` = '%s', `received` = '%s', `global` = %d WHERE `otype` = %d AND `oid` = %d",
-                               dbesc($message['guid']), dbesc($message['created']), dbesc($message['received']),
-                               intval($global), intval(TERM_OBJ_POST), intval($message['oid']));
+                       $fields = ['guid' => $message['guid'], 'created' => $message['created'],
+                               'received' => $message['received'], 'global' => $global];
+                       dba::update('term', $fields, ['otype' => TERM_OBJ_POST, 'oid' => $message['oid']]);
                }
 
                dba::close($messages);
@@ -33,7 +31,7 @@ class TagUpdate
 
                logger('fetched messages: ' . dba::num_rows($messages));
                while ($message = dba::fetch(messages)) {
-                       q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($message['guid']));
+                       dba::update('item', ['global' => true], ['guid' => $message['guid']]);
                }
 
                dba::close($messages);