X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FMergeContacts.php;h=f04b64a23dc4b1507bd0570995ac5e1ed8a02214;hb=af2a38c5b3724d140700316f3a0251e82692de38;hp=79cd0b4b749ae431e49e6cb22f904f077e2eb4ad;hpb=b1afcb5ebfb270f7419339a636293890ce2da8ea;p=friendica.git diff --git a/src/Console/MergeContacts.php b/src/Console/MergeContacts.php index 79cd0b4b74..f04b64a23d 100644 --- a/src/Console/MergeContacts.php +++ b/src/Console/MergeContacts.php @@ -1,6 +1,6 @@ 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)) { $this->out($this->l10n->t('%d %s, %d duplicates.', $duplicate['uri-id'], $duplicate['url'], $duplicate['total'])); if ($this->getOption(['e', 'execute'], false)) { + if (empty($duplicate['uri-id'])) { + $this->err($this->l10n->t('uri-id is empty for contact %s.', $duplicate['url'])); + continue; + } $this->mergeContacts($duplicate['uri-id']); } } @@ -83,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']); @@ -133,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));