]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/MergeContacts.php
bump version 2023.12
[friendica.git] / src / Console / MergeContacts.php
index 543ad316e7f9fc48c3f92589282c1e9c9e58095a..f04b64a23dc4b1507bd0570995ac5e1ed8a02214 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,6 +23,7 @@ namespace Friendica\Console;
 
 use Friendica\Core\L10n;
 use Friendica\Database\Database;
+use Friendica\Model\Contact;
 
 /**
  * tool to find and merge duplicated contact entries.
@@ -67,7 +68,7 @@ HELP;
                $this->l10n = $l10n;
        }
 
-       protected function doExecute()
+       protected function doExecute(): int
        {
                $duplicates = $this->dba->p("SELECT COUNT(*) AS `total`, `uri-id`, MAX(`url`) AS `url` FROM `contact` WHERE `uid` = 0 GROUP BY `uri-id` HAVING total > 1");
                while ($duplicate = $this->dba->fetch($duplicates)) {
@@ -87,7 +88,7 @@ HELP;
        {
                $first = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ["`uri-id` = ? AND `nurl` != ? AND `url` != ?", $uriid, '', ''], ['order' => ['id']]);
                if (empty($first)) {
-                       $this->err($this->l10n->t('No valid first countact found for uri-id %d.', $uriid));
+                       $this->err($this->l10n->t('No valid first contact found for uri-id %d.', $uriid));
                        return;
                }
                $this->out($first['url']);
@@ -137,7 +138,7 @@ HELP;
                $this->updateTable('post-thread-user', 'contact-id', $from, $to, false);
                $this->updateTable('user-contact', 'cid', $from, $to, true);
 
-               if (!$this->dba->delete('contact', ['id' => $from])) {
+               if (!Contact::deleteById($from)) {
                        $this->err($this->l10n->t('Deletion of id %d failed', $from));
                } else {
                        $this->out($this->l10n->t('Deletion of id %d was successful', $from));