1
1
Fork 0

Don't handle deleted contacts / removed unneeded parameter

This commit is contained in:
Michael Vogel 2019-08-29 07:22:29 +02:00
parent 503a5be06c
commit 66eab2b44f
2 changed files with 9 additions and 10 deletions

View file

@ -436,8 +436,8 @@ class PostUpdate
$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);

View file

@ -149,14 +149,14 @@ class Contact extends BaseObject
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;
}
@ -1878,7 +1878,7 @@ class Contact extends BaseObject
}
// 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;
}
@ -1927,13 +1927,13 @@ class Contact extends BaseObject
*/
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;
}
@ -1943,11 +1943,10 @@ class Contact extends BaseObject
*
* @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);
@ -1962,7 +1961,7 @@ class Contact extends BaseObject
}
$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]);