mirror of
https://github.com/friendica/friendica
synced 2024-12-23 14:40:16 +00:00
Don't handle deleted contacts / removed unneeded parameter
This commit is contained in:
parent
503a5be06c
commit
66eab2b44f
2 changed files with 9 additions and 10 deletions
|
@ -436,8 +436,8 @@ class PostUpdate
|
||||||
|
|
||||||
$contacts = DBA::p("SELECT ANY_VALUE(`id`) AS `id`, ANY_VALUE(`nurl`) AS `nurl` FROM `contact`
|
$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 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 (?, ?, ?))
|
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` = ?)) GROUP BY `nurl`, `uid`",
|
AND (`network` IN (?, ?, ?) OR (`uid` = ?)) AND NOT `deleted` GROUP BY `nurl`, `uid`",
|
||||||
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB,
|
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB,
|
||||||
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB, 0);
|
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB, 0);
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,14 @@ class Contact extends BaseObject
|
||||||
public static function insert($param, $on_duplicate_update = false)
|
public static function insert($param, $on_duplicate_update = false)
|
||||||
{
|
{
|
||||||
$ret = DBA::insert('contact', $param, $on_duplicate_update);
|
$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)) {
|
if (!DBA::isResult($contact)) {
|
||||||
// Shouldn't happen
|
// Shouldn't happen
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for duplicated contacts and get rid of them
|
// 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;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -1878,7 +1878,7 @@ class Contact extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for duplicated contacts and get rid of them
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1927,13 +1927,13 @@ class Contact extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function handleDuplicateByID($contact_id)
|
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)) {
|
if (!DBA::isResult($contact)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for duplicated contacts and get rid of them
|
// Search for duplicated contacts and get rid of them
|
||||||
self::handleDuplicates($contact['nurl'], $contact['uid'], $contact['id']);
|
self::handleDuplicates($contact['nurl'], $contact['uid']);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1943,11 +1943,10 @@ class Contact extends BaseObject
|
||||||
*
|
*
|
||||||
* @param string $nurl Normalised contact url
|
* @param string $nurl Normalised contact url
|
||||||
* @param integer $uid User id
|
* @param integer $uid User id
|
||||||
* @param integer $id Contact id of a duplicate
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws \Exception
|
* @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];
|
$condition = ['nurl' => $nurl, 'uid' => $uid, 'deleted' => false, 'network' => Protocol::FEDERATED];
|
||||||
$count = DBA::count('contact', $condition);
|
$count = DBA::count('contact', $condition);
|
||||||
|
@ -1962,7 +1961,7 @@ class Contact extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
$first = $first_contact['id'];
|
$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))) {
|
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)
|
// 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]);
|
Logger::info('Not handling non public DFRN duplicate', ['uid' => $uid, 'nurl' => $nurl]);
|
||||||
|
|
Loading…
Reference in a new issue