]> git.mxchange.org Git - friendica.git/commitdiff
Use centralized function to update contact entries
authorMichael <heluecht@pirati.ca>
Fri, 10 Sep 2021 18:21:19 +0000 (18:21 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 10 Sep 2021 18:21:19 +0000 (18:21 +0000)
20 files changed:
include/api.php
mod/pubsub.php
mod/unfollow.php
src/Console/ArchiveContact.php
src/Console/GlobalCommunitySilence.php
src/Model/Contact.php
src/Model/Contact/Relation.php
src/Model/Introduction.php
src/Model/Item.php
src/Module/Api/Mastodon/Accounts/Note.php
src/Module/Contact.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Transmitter.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/Feed.php
src/Protocol/OStatus.php
src/Protocol/Relay.php
src/Worker/OnePoll.php
src/Worker/RemoveUnusedAvatars.php

index e0cac831e5644b7fe492e5b55fde4de4402cd43a..7758a5eaf2dd02336726fa31f3782fc25896e81f 100644 (file)
@@ -3848,7 +3848,7 @@ function api_friendships_destroy($type)
        if ($dissolve) {
                Contact::remove($contact['id']);
        } else {
-               DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
+               Contact::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
        }
 
        // "uid" and "self" are only needed for some internal stuff, so remove it from here
@@ -4504,14 +4504,14 @@ function api_account_update_profile($type)
        if (!empty($_POST['name'])) {
                DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
                DBA::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
-               DBA::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
-               DBA::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
+               Contact::update(['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
+               Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
        }
 
        if (isset($_POST['description'])) {
                DBA::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
-               DBA::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
-               DBA::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
+               Contact::update(['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
+               Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
        }
 
        Profile::publishUpdate($local_user);
index 9b73ff85e23a11c72da30c3eca8b504b4a565f0b..1dfbd0b3dc9960f72848dc156400f6e2e489b5d9 100644 (file)
@@ -96,7 +96,7 @@ function pubsub_init(App $a)
                }
 
                if (!empty($hub_mode)) {
-                       DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]);
+                       Contact::update(['subhub' => $subscribe], ['id' => $contact['id']]);
                        Logger::log($hub_mode . ' success for contact ' . $contact_id . '.');
                }
                hub_return(true, $hub_challenge);
index de1cb6cf7cdb05dd02a69c2bbc6447c59295f42b..f1117674df8d167ccb514581aa782ed893d41461 100644 (file)
@@ -149,7 +149,7 @@ function unfollow_process(string $url)
                Contact::remove($contact['id']);
                $return_path = $base_return_path;
        } else {
-               DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
+               Contact::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
                $return_path = $base_return_path . '/' . $contact['id'];
        }
 
index 24251bcce521c37eb6fd11ef78b840681c032f66..e3ccc4811983bf4cc1bb0a5398bc4f919ff8890b 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Console;
 use Friendica\App;
 use Friendica\Database\Database;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Util\Strings;
 use RuntimeException;
 
@@ -104,7 +105,7 @@ HELP;
                if (!$this->dba->exists('contact', ['nurl' => $nurl, 'archive' => false])) {
                        throw new RuntimeException(DI::l10n()->t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
                }
-               if ($this->dba->update('contact', ['archive' => true], ['nurl' => $nurl])) {
+               if (Contact::update(['archive' => true], ['nurl' => $nurl])) {
                        $this->out($this->l10n->t('The contact entries have been archived'));
                } else {
                        throw new RuntimeException('The contact archival failed.');
index d74892b340b8549a1a42e0e81cc93fa81e71a08a..2e65109e8b892ae27ee908346cfaad4f42a6ce12 100644 (file)
@@ -98,7 +98,7 @@ HELP;
 
                $contact_id = Contact::getIdForURL($this->getArgument(0));
                if ($contact_id) {
-                       $this->dba->update('contact', ['hidden' => true], ['id' => $contact_id]);
+                       Contact::update(['hidden' => true], ['id' => $contact_id]);
                        $this->out('The account has been successfully silenced from the global community page.');
                } else {
                        throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');
index 2cc1c091ebe8aeeeb7221e5bcae2f1d16e1b85ad..8c84625931b195450cd5a98845022d2cca248ac4 100644 (file)
@@ -208,6 +208,23 @@ class Contact
                return $contact['id'];
        }
 
+       /**
+        * Updates rows in the contact table
+        *
+        * @param array         $fields     contains the fields that are updated
+        * @param array         $condition  condition array with the key values
+        * @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
+        *
+        * @return boolean was the update successfull?
+        * @throws \Exception
+        */
+       public static function update(array $fields, array $condition, $old_fields = [])
+       {
+               $ret = DBA::update('contact', $fields, $condition, $old_fields);
+               // @todo Apply changes to the "user-contact" table on dedicated fields
+               return $ret;
+       }
+
        /**
         * @param integer $id     Contact ID
         * @param array   $fields Array of selected fields, empty for all
@@ -765,12 +782,12 @@ class Contact
                                $fields['name-date'] = DateTimeFormat::utcNow();
                        }
                        $fields['updated'] = DateTimeFormat::utcNow();
-                       DBA::update('contact', $fields, ['id' => $self['id']]);
+                       self::update($fields, ['id' => $self['id']]);
 
                        // Update the public contact as well
                        $fields['prvkey'] = null;
                        $fields['self']   = false;
-                       DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
+                       self::update($fields, ['uid' => 0, 'nurl' => $self['nurl']]);
 
                        // Update the profile
                        $fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
@@ -797,7 +814,7 @@ class Contact
                }
 
                // Archive the contact
-               DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
+               self::update(['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
 
                // Delete it in the background
                Worker::add(PRIORITY_MEDIUM, 'RemoveContact', $id);
@@ -883,8 +900,8 @@ class Contact
                }
 
                if ($contact['term-date'] <= DBA::NULL_DATETIME) {
-                       DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
-                       DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', Strings::normaliseLink($contact['url']), DBA::NULL_DATETIME]);
+                       self::update(['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+                       self::update(['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', Strings::normaliseLink($contact['url']), DBA::NULL_DATETIME]);
                } else {
                        /* @todo
                         * We really should send a notification to the owner after 2-3 weeks
@@ -901,8 +918,8 @@ class Contact
                                 * delete, though if the owner tries to unarchive them we'll start
                                 * the whole process over again.
                                 */
-                               DBA::update('contact', ['archive' => true], ['id' => $contact['id']]);
-                               DBA::update('contact', ['archive' => true], ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
+                               self::update(['archive' => true], ['id' => $contact['id']]);
+                               self::update(['archive' => true], ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
                        }
                }
        }
@@ -923,7 +940,7 @@ class Contact
                        $fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
                        $condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
                        if (!DBA::exists('contact', array_merge($condition, $fields))) {
-                               DBA::update('contact', $fields, $condition);
+                               self::update($fields, $condition);
                        }
                }
 
@@ -947,8 +964,8 @@ class Contact
 
                // It's a miracle. Our dead contact has inexplicably come back to life.
                $fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
-               DBA::update('contact', $fields, ['id' => $contact['id']]);
-               DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
+               self::update($fields, ['id' => $contact['id']]);
+               self::update($fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
        }
 
        /**
@@ -1496,7 +1513,7 @@ class Contact
         */
        public static function block($cid, $reason = null)
        {
-               $return = DBA::update('contact', ['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
+               $return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
 
                return $return;
        }
@@ -1510,7 +1527,7 @@ class Contact
         */
        public static function unblock($cid)
        {
-               $return = DBA::update('contact', ['blocked' => false, 'block_reason' => null], ['id' => $cid]);
+               $return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]);
 
                return $return;
        }
@@ -1809,7 +1826,7 @@ class Contact
                // Only update the cached photo links of public contacts when they already are cached
                if (($uid == 0) && !$force && empty($contact['thumb']) && empty($contact['micro']) && !$create_cache) {
                        if ($contact['avatar'] != $avatar) {
-                               DBA::update('contact', ['avatar' => $avatar], ['id' => $cid]);
+                               self::update(['avatar' => $avatar], ['id' => $cid]);
                                Logger::info('Only update the avatar', ['id' => $cid, 'avatar' => $avatar, 'contact' => $contact]);
                        }
                        return;
@@ -1906,7 +1923,7 @@ class Contact
                $cids[] = $cid;
                $uids[] = $uid;
                Logger::info('Updating cached contact avatars', ['cid' => $cids, 'uid' => $uids, 'fields' => $fields]);
-               DBA::update('contact', $fields, ['id' => $cids]);
+               self::update($fields, ['id' => $cids]);
        }
 
        public static function deleteContactByUrl(string $url)
@@ -1933,7 +1950,7 @@ class Contact
         */
        private static function updateContact(int $id, int $uid, string $old_url, string $new_url, array $fields)
        {
-               if (!DBA::update('contact', $fields, ['id' => $id])) {
+               if (!self::update($fields, ['id' => $id])) {
                        Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
                        return;
                }
@@ -1966,7 +1983,7 @@ class Contact
                $condition = ['self' => false, 'nurl' => Strings::normaliseLink($old_url)];
 
                $condition['network'] = [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB];
-               DBA::update('contact', $fields, $condition);
+               self::update($fields, $condition);
 
                // We mustn't set the update fields for OStatus contacts since they are updated in OnePoll
                $condition['network'] = Protocol::OSTATUS;
@@ -1982,7 +1999,7 @@ class Contact
                        return;
                }
 
-               DBA::update('contact', $fields, $condition);
+               self::update($fields, $condition);
        }
 
        /**
@@ -2256,7 +2273,7 @@ class Contact
                        }
                }
                if (!empty($fields)) {
-                       DBA::update('contact', $fields, ['id' => $id, 'self' => false]);
+                       self::update($fields, ['id' => $id, 'self' => false]);
                        Logger::info('Updating local contact', ['id' => $id]);
                }
        }
@@ -2434,7 +2451,7 @@ class Contact
                        $new_relation = (($contact['rel'] == self::FOLLOWER) ? self::FRIEND : self::SHARING);
 
                        $fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
-                       DBA::update('contact', $fields, ['id' => $contact['id']]);
+                       self::update($fields, ['id' => $contact['id']]);
                } else {
                        $new_relation = (in_array($protocol, [Protocol::MAIL]) ? self::FRIEND : self::SHARING);
 
@@ -2567,7 +2584,7 @@ class Contact
                        $fields = ['url' => $contact['url'], 'request' => $contact['request'],
                                        'notify' => $contact['notify'], 'poll' => $contact['poll'],
                                        'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
-                       DBA::update('contact', $fields, ['id' => $contact['id']]);
+                       self::update($fields, ['id' => $contact['id']]);
                }
 
                return $contact;
@@ -2670,7 +2687,7 @@ class Contact
 
                        if (($contact['rel'] == self::SHARING)
                                || ($sharing && $contact['rel'] == self::FOLLOWER)) {
-                               DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
+                               self::update(['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
                                                ['id' => $contact['id'], 'uid' => $importer['uid']]);
                        }
 
@@ -2750,7 +2767,7 @@ class Contact
                                        $fields['rel'] = self::FRIEND;
                                }
 
-                               DBA::update('contact', $fields, $condition);
+                               self::update($fields, $condition);
 
                                return true;
                        }
@@ -2762,7 +2779,7 @@ class Contact
        public static function removeFollower($importer, $contact)
        {
                if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
-                       DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
+                       self::update(['rel' => self::SHARING], ['id' => $contact['id']]);
                } else {
                        self::remove($contact['id']);
                }
@@ -2771,7 +2788,7 @@ class Contact
        public static function removeSharer($importer, $contact)
        {
                if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::FOLLOWER)) {
-                       DBA::update('contact', ['rel' => self::FOLLOWER], ['id' => $contact['id']]);
+                       self::update(['rel' => self::FOLLOWER], ['id' => $contact['id']]);
                } else {
                        self::remove($contact['id']);
                }
index b9d38790db5bf4b1a88a1f55a9cd7d3b60ff6e44..565d076a7f451ed2385057e502c448dc1978f593 100644 (file)
@@ -114,7 +114,7 @@ class Relation
                }
 
                if (empty($followers) && empty($followings)) {
-                       DBA::update('contact', ['last-discovery' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+                       Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
                        Logger::info('The contact does not offer discoverable data', ['id' => $contact['id'], 'url' => $url, 'network' => $contact['network']]);
                        return;
                }
@@ -162,7 +162,7 @@ class Relation
                        DBA::delete('contact-relation', ['cid' => $target, 'follows' => false, 'last-interaction' => DBA::NULL_DATETIME]);
                }
 
-               DBA::update('contact', ['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
+               Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
                Logger::info('Contacts discovery finished', ['id' => $target, 'url' => $url, 'follower' => $follower_counter, 'following' => $following_counter]);
                return;
        }
index 849cad78b853689b5627972dba39a1e985348c72..aa718912143dc520f71a1e80db9de22e51189560 100644 (file)
@@ -110,7 +110,7 @@ class Introduction extends BaseModel
                        'hidden'    => $hidden ?? $contact['hidden'],
                        'rel'       => $newRelation,
                ];
-               $this->dba->update('contact', $fields, ['id' => $contact['id']]);
+               Contact::update($fields, ['id' => $contact['id']]);
 
                array_merge($contact, $fields);
 
@@ -159,7 +159,7 @@ class Introduction extends BaseModel
                        if ($this->dba->exists('contact', $condition)) {
                                Contact::remove($this->{'contact-id'});
                        } else {
-                               $this->dba->update('contact', ['pending' => false], ['id' => $this->{'contact-id'}]);
+                               Contact::update(['pending' => false], ['id' => $this->{'contact-id'}]);
                        }
                }
 
index 5cc72b05800bc15ebc60a92effb08baf3c553b8e..7406bb2907be6c7ef9957a74471bda03baecd425 100644 (file)
@@ -1753,15 +1753,15 @@ class Item
                        } else {
                                $condition = ['id' => $arr['contact-id'], 'self' => false];
                        }
-                       DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']], $condition);
+                       Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']], $condition);
                }
                // Now do the same for the system wide contacts with uid=0
                if ($arr['private'] != self::PRIVATE) {
-                       DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
+                       Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
                                ['id' => $arr['owner-id']]);
 
                        if ($arr['owner-id'] != $arr['author-id']) {
-                               DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
+                               Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
                                        ['id' => $arr['author-id']]);
                        }
                }
index bb5778a0f70984c712146c2e4585fa8cdde5e311..e6319220244a26e1887540bf1b65b7cc297b9282 100644 (file)
@@ -50,7 +50,7 @@ class Note extends BaseApi
                        DI::mstdnError()->RecordNotFound();
                }
 
-               DBA::update('contact', ['info' => $request['comment']], ['id' => $cdata['user']]);
+               Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
 
                System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
        }
index 6f32356a3260b81c408bdde0255e01c4b4ce76ed..dac706c2f6a2dcd7c5aaba7e0fe90ab28fb36103 100644 (file)
@@ -139,7 +139,7 @@ class Contact extends BaseModule
 
                $info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
 
-               $r = DBA::update('contact', [
+               $r = Model\Contact::update([
                        'priority'   => $priority,
                        'info'       => $info,
                        'hidden'     => $hidden,
@@ -175,7 +175,7 @@ class Contact extends BaseModule
                        $result = Model\Contact::createFromProbeForUser($contact['uid'], $contact['url'], $contact['network']);
 
                        if ($result['success']) {
-                               DBA::update('contact', ['subhub' => 1], ['id' => $contact_id]);
+                               Model\Contact::update(['subhub' => 1], ['id' => $contact_id]);
                        }
 
                        // pull feed and consume it, which should subscribe to the hub.
index 47a5300352d03ee73104ad05290d4f134c4035b8..414c7192126fac0f5cb4bba44ca2efd3f85cb20a 100644 (file)
@@ -912,7 +912,7 @@ class Processor
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (!empty($cid)) {
                        self::switchContact($cid);
-                       DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
+                       Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
                }
 
                $item = ['author-id' => Contact::getIdForURL($activity['actor']),
@@ -932,7 +932,7 @@ class Processor
                }
 
                if (empty($contact)) {
-                       DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
+                       Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
                }
 
                Logger::notice('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
@@ -1011,7 +1011,7 @@ class Processor
                }
 
                $condition = ['id' => $cid];
-               DBA::update('contact', $fields, $condition);
+               Contact::update($fields, $condition);
                Logger::info('Accept contact request', ['contact' => $cid, 'user' => $uid]);
        }
 
index bd43eea04893a796deb4b57afea4930f54598f8a..daed50d0b2c47a8839bc5b925b2b332ef03faa62 100644 (file)
@@ -115,7 +115,7 @@ class Transmitter
                $activity_id = ActivityPub\Transmitter::activityIDFromContact($contact['id']);
                $success = ActivityPub\Transmitter::sendActivity('Follow', $url, 0, $activity_id);
                if ($success) {
-                       DBA::update('contact', ['rel' => Contact::FRIEND], ['id' => $contact['id']]);
+                       Contact::update(['rel' => Contact::FRIEND], ['id' => $contact['id']]);
                }
 
                return $success;
@@ -137,7 +137,7 @@ class Transmitter
 
                $success = self::sendContactUndo($url, $contact['id'], 0);
                if ($success || $force) {
-                       DBA::update('contact', ['rel' => Contact::NOTHING], ['id' => $contact['id']]);
+                       Contact::update(['rel' => Contact::NOTHING], ['id' => $contact['id']]);
                }
 
                return $success;
index 4ccd259f21c71655c6ff9e5ada0a3b538eae5565..44518e15c17a025d1ee504ab0c9867136cac0f25 100644 (file)
@@ -1215,12 +1215,12 @@ class DFRN
                                'xmpp' => $contact['xmpp'], 'name-date' => DateTimeFormat::utc($contact['name-date']),
                                'unsearchable' => $contact['hidden'], 'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
 
-                       DBA::update('contact', $fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
+                       Contact::update($fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
 
                        // Update the public contact. Don't set the "hidden" value, this is used differently for public contacts
                        unset($fields['hidden']);
                        $condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($contact_old['url'])];
-                       DBA::update('contact', $fields, $condition, true);
+                       Contact::update($fields, $condition, true);
 
                        Contact::updateAvatar($contact['id'], $author['avatar']);
 
@@ -1400,7 +1400,7 @@ class DFRN
                        'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
                $condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], Strings::normaliseLink($old["url"])];
 
-               DBA::update('contact', $fields, $condition);
+               Contact::update($fields, $condition);
 
                Contact::updateAvatar($importer["id"], $relocate["avatar"], true);
 
@@ -2200,36 +2200,36 @@ class DFRN
                        $accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
 
                        if ($accounttype != $importer["contact-type"]) {
-                               DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer['id']]);
+                               Contact::update(['contact-type' => $accounttype], ['id' => $importer['id']]);
 
                                // Updating the public contact as well
-                               DBA::update('contact', ['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
+                               Contact::update(['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
                        }
                        // A forum contact can either have set "forum" or "prv" - but not both
                        if ($accounttype == User::ACCOUNT_TYPE_COMMUNITY) {
                                // It's a forum, so either set the public or private forum flag
                                $condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer['id']];
-                               DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
+                               Contact::update(['forum' => $forum, 'prv' => !$forum], $condition);
 
                                // Updating the public contact as well
                                $condition = ['(`forum` != ? OR `prv` != ?) AND `uid` = 0 AND `nurl` = ?', $forum, !$forum, $importer['nurl']];
-                               DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
+                               Contact::update(['forum' => $forum, 'prv' => !$forum], $condition);
                        } else {
                                // It's not a forum, so remove the flags
                                $condition = ['(`forum` OR `prv`) AND `id` = ?', $importer['id']];
-                               DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
+                               Contact::update(['forum' => false, 'prv' => false], $condition);
 
                                // Updating the public contact as well
                                $condition = ['(`forum` OR `prv`) AND `uid` = 0 AND `nurl` = ?', $importer['nurl']];
-                               DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
+                               Contact::update(['forum' => false, 'prv' => false], $condition);
                        }
                } elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
                        $condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
-                       DBA::update('contact', ['forum' => $forum], $condition);
+                       Contact::update(['forum' => $forum], $condition);
 
                        // Updating the public contact as well
                        $condition = ['`forum` != ? AND `uid` = 0 AND `nurl` = ?', $forum, $importer['nurl']];
-                       DBA::update('contact', ['forum' => $forum], $condition);
+                       Contact::update(['forum' => $forum], $condition);
                }
 
 
index 48d7a3371cbfd49c62700b2da5fd30701f940213..8fadf5ed445eeaedc3c4667cd6bb6b7c49b72e33 100644 (file)
@@ -1367,7 +1367,7 @@ class Diaspora
                                'notify' => $data['notify'], 'poll' => $data['poll'],
                                'network' => $data['network']];
 
-               DBA::update('contact', $fields, ['addr' => $old_handle]);
+               Contact::update($fields, ['addr' => $old_handle]);
 
                Logger::log('Contacts are updated.');
 
@@ -2129,7 +2129,7 @@ class Diaspora
                        $fields['bd'] = $birthday;
                }
 
-               DBA::update('contact', $fields, ['id' => $contact['id']]);
+               Contact::update($fields, ['id' => $contact['id']]);
 
                Logger::log("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], Logger::DEBUG);
 
index 07fa04518a3bdcbc95c917d68b5d0fd7e5a3c1fe..8c0d1f96f8f5b9bdee4787ffc42fe0c2867e29dc 100644 (file)
@@ -732,7 +732,7 @@ class Feed
 
                if ($contact['rating'] != $priority) {
                        Logger::notice('Adjusting priority', ['old' => $contact['rating'], 'new' => $priority, 'id' => $contact['id'], 'uid' => $contact['uid'], 'url' => $contact['url']]);
-                       DBA::update('contact', ['rating' => $priority], ['id' => $contact['id']]);
+                       Contact::update(['rating' => $priority], ['id' => $contact['id']]);
                }
        }
 
index 2404db2df92dcf93fdc9b1bdb9be4f52adaf3d51..b0b9bd7d0ed37c899c3ef25622dc5b6cff3d05e9 100644 (file)
@@ -209,7 +209,7 @@ class OStatus
 
                        $contact['name-date'] = DateTimeFormat::utcNow();
 
-                       DBA::update('contact', $contact, ['id' => $contact["id"]], $current);
+                       Contact::update($contact, ['id' => $contact["id"]], $current);
 
                        if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
                                Logger::log("Update profile picture for contact ".$contact["id"], Logger::DEBUG);
@@ -230,7 +230,7 @@ class OStatus
                                                'about' => $contact["about"], 'location' => $contact["location"],
                                                'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
 
-                               DBA::update('contact', $fields, ['id' => $cid], $old_contact);
+                               Contact::update($fields, ['id' => $cid], $old_contact);
 
                                // Update the avatar
                                if (!empty($author["author-avatar"])) {
index f89dc3999930d48e47ee83044183a2210333454e..b604f5ab37951459d22ee643c7055ecdacd6cfca 100644 (file)
@@ -166,7 +166,7 @@ class Relay
                        $fields['updated'] = DateTimeFormat::utcNow();
 
                        Logger::info('Update relay contact', ['server' => $gserver['url'], 'id' => $old['id'], 'fields' => $fields]);
-                       DBA::update('contact', $fields, ['id' => $old['id']], $old);
+                       Contact::update($fields, ['id' => $old['id']], $old);
                } else {
                        $default = ['created' => DateTimeFormat::utcNow(),
                                'name' => 'relay', 'nick' => 'relay', 'url' => $gserver['url'],
index e1f0f61080d34db537e5599ade444b37287c470f..99d5054ca3b8727ed9077d3410abdeb1f749e62c 100644 (file)
@@ -82,7 +82,7 @@ class OnePoll
                                Logger::warning('No self contact for user', ['uid' => $importer_uid]);
 
                                // set the last-update so we don't keep polling
-                               DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
+                               Contact::update(['last-update' => $updated], ['id' => $contact['id']]);
                                return;
                        }
 
@@ -122,16 +122,16 @@ class OnePoll
        {
                if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL, Protocol::OSTATUS])) {
                        // Update the user's contact
-                       DBA::update('contact', $fields, ['id' => $contact['id']]);
+                       Contact::update($fields, ['id' => $contact['id']]);
 
                        // Update the public contact
-                       DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
 
                        // Update the rest of the contacts that aren't polled
-                       DBA::update('contact', $fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
                } else {
                        // Update all contacts
-                       DBA::update('contact', $fields, ['nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['nurl' => $contact['nurl']]);
                }
        }
 
@@ -456,7 +456,7 @@ class OnePoll
                Logger::info('Hub subscription start', ['mode' => $hubmode, 'name' => $contact['name'], 'hub' => $url, 'endpoint' => $push_url, 'verifier' => $verify_token]);
 
                if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
-                       DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
+                       Contact::update(['hub-verify' => $verify_token], ['id' => $contact['id']]);
                }
 
                $postResult = DI::httpClient()->post($url, $params);
index 58670c87350a45bc928e06a79aadb608d4427b0c..7fdbeb7eccd847805f67bb8f3bc27835b75259cf 100644 (file)
@@ -44,7 +44,7 @@ class RemoveUnusedAvatars
                $count = 0;
                $contacts = DBA::select('contact', ['id'], $condition);
                while ($contact = DBA::fetch($contacts)) {
-                       DBA::update('contact', ['photo' => '', 'thumb' => '', 'micro' => ''], ['id' => $contact['id']]);
+                       Contact::update(['photo' => '', 'thumb' => '', 'micro' => ''], ['id' => $contact['id']]);
                        Photo::delete(['contact-id' => $contact['id'], 'album' => Photo::CONTACT_PHOTOS]);
                        if ((++$count % 1000) == 0) {
                                if (!Worker::isInMaintenanceWindow()) {