From: Michael Date: Sat, 18 Apr 2020 16:00:06 +0000 (+0000) Subject: Hybrid mode for non resolvable contacts X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0f2215bc175f0d3832eb44cd3643edc16780923b;p=friendica.git Hybrid mode for non resolvable contacts --- diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 7627872590..6de872a9e5 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -23,7 +23,7 @@ namespace Friendica\Model; use Friendica\Core\Logger; use Friendica\Database\DBA; -use Friendica\Model\Contact; +use Friendica\Util\Strings; /** * Class Tag @@ -69,6 +69,9 @@ class Tag return; } + $cid = 0; + $tagid = 0; + if (in_array($type, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION])) { if (empty($url)) { // No mention without a contact url @@ -77,13 +80,18 @@ class Tag Logger::info('Get ID for contact', ['url' => $url]); - $cid = Contact::getIdForURL($url, 0, true); - if (empty($cid)) { - Logger::error('No contact found', ['url' => $url]); - return; + $condition = ['nurl' => Strings::normaliseLink($url), 'uid' => 0, 'deleted' => false]; + $contact = DBA::selectFirst('contact', ['id'], $condition, ['order' => ['id']]); + if (DBA::isResult($contact)) { + $cid = $contact['id']; + } else { + // The contact wasn't found in the system (most likely some dead account) + // We ensure that we only store a single entry by overwriting the previous name + DBA::update('tag', ['name' => substr($name, 0, 96)], ['url' => $url]); } - $tagid = 0; - } else { + } + + if (empty($cid)) { $fields = ['name' => substr($name, 0, 96)]; if (!empty($url) && ($url != $name)) { @@ -102,7 +110,6 @@ class Tag Logger::error('No tag id created', $fields); return; } - $cid = 0; } DBA::insert('post-tag', ['uri-id' => $uriid, 'type' => $type, 'tid' => $tagid, 'cid' => $cid], true); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index e0c3c5b70e..d6bd418f8a 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -1301,7 +1301,8 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], - "type_name_url" => ["UNIQUE", "name", "url"] + "type_name_url" => ["UNIQUE", "name", "url"], + "url" => ["url"] ] ], "post-tag" => [