$contacts = DBA::p("SELECT ANY_VALUE(`id`) AS `id`, ANY_VALUE(`nurl`) AS `nurl` FROM `contact`
WHERE EXISTS (SELECT `nurl` FROM `contact` AS `c2`
- WHERE `c2`.`nurl` = `contact`.`nurl` AND `c2`.`id` != `contact`.`id` AND `c2`.`uid` = `contact`.`uid` AND `c2`.`network` IN (?, ?, ?))
- AND (`network` IN (?, ?, ?) OR (`uid` = ?)) GROUP BY `nurl`, `uid`",
+ WHERE `c2`.`nurl` = `contact`.`nurl` AND `c2`.`id` != `contact`.`id` AND `c2`.`uid` = `contact`.`uid` AND `c2`.`network` IN (?, ?, ?) AND NOT `deleted`)
+ AND (`network` IN (?, ?, ?) OR (`uid` = ?)) AND NOT `deleted` GROUP BY `nurl`, `uid`",
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB,
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB, 0);
public static function insert($param, $on_duplicate_update = false)
{
$ret = DBA::insert('contact', $param, $on_duplicate_update);
- $contact = DBA::selectFirst('contact', ['nurl', 'uid', 'id'], ['id' => DBA::lastInsertId()]);
+ $contact = DBA::selectFirst('contact', ['nurl', 'uid'], ['id' => DBA::lastInsertId()]);
if (!DBA::isResult($contact)) {
// Shouldn't happen
return $ret;
}
// Search for duplicated contacts and get rid of them
- self::handleDuplicates($contact['nurl'], $contact['uid'], $contact['id']);
+ self::handleDuplicates($contact['nurl'], $contact['uid']);
return $ret;
}
}
// Search for duplicated contacts and get rid of them
- if (self::handleDuplicates(Strings::normaliseLink($url), $uid, $id) || ($uid != 0)) {
+ if (self::handleDuplicates(Strings::normaliseLink($url), $uid) || ($uid != 0)) {
return;
}
*/
public static function handleDuplicateByID($contact_id)
{
- $contact = DBA::selectFirst('contact', ['nurl', 'uid', 'id'], ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', ['nurl', 'uid'], ['id' => $contact_id, 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
// Search for duplicated contacts and get rid of them
- self::handleDuplicates($contact['nurl'], $contact['uid'], $contact['id']);
+ self::handleDuplicates($contact['nurl'], $contact['uid']);
return;
}
*
* @param string $nurl Normalised contact url
* @param integer $uid User id
- * @param integer $id Contact id of a duplicate
* @return boolean
* @throws \Exception
*/
- private static function handleDuplicates($nurl, $uid, $id)
+ private static function handleDuplicates($nurl, $uid)
{
$condition = ['nurl' => $nurl, 'uid' => $uid, 'deleted' => false, 'network' => Protocol::FEDERATED];
$count = DBA::count('contact', $condition);
}
$first = $first_contact['id'];
- Logger::info('Found duplicates', ['count' => $count, 'id' => $id, 'first' => $first, 'uid' => $uid, 'nurl' => $nurl]);
+ Logger::info('Found duplicates', ['count' => $count, 'first' => $first, 'uid' => $uid, 'nurl' => $nurl]);
if (($uid != 0 && ($first_contact['network'] == Protocol::DFRN))) {
// Don't handle non public DFRN duplicates by now (legacy DFRN is very special because of the key handling)
Logger::info('Not handling non public DFRN duplicate', ['uid' => $uid, 'nurl' => $nurl]);