4 * @file src/Worker/MergeContact.php
7 namespace Friendica\Worker;
9 use Friendica\Core\Logger;
10 use Friendica\Database\DBA;
14 public static function execute($first, $dup_id, $uid)
16 if (empty($first) || empty($dup_id) || ($first == $dup_id)) {
21 Logger::info('Handling duplicate', ['search' => $dup_id, 'replace' => $first]);
24 DBA::update('item', ['contact-id' => $first], ['contact-id' => $dup_id]);
25 DBA::update('thread', ['contact-id' => $first], ['contact-id' => $dup_id]);
26 DBA::update('mail', ['contact-id' => $first], ['contact-id' => $dup_id]);
27 DBA::update('photo', ['contact-id' => $first], ['contact-id' => $dup_id]);
28 DBA::update('event', ['cid' => $first], ['cid' => $dup_id]);
30 DBA::update('item', ['author-id' => $first], ['author-id' => $dup_id]);
31 DBA::update('item', ['owner-id' => $first], ['owner-id' => $dup_id]);
32 DBA::update('thread', ['author-id' => $first], ['author-id' => $dup_id]);
33 DBA::update('thread', ['owner-id' => $first], ['owner-id' => $dup_id]);
35 /// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
38 // Remove the duplicate
39 DBA::delete('contact', ['id' => $dup_id]);