From: Michael Date: Mon, 29 May 2023 06:41:07 +0000 (+0000) Subject: Ensure to store user-contact / display contact relations X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a42ddafbbb1034cd997c7e564ca5018346fb31b5;p=friendica.git Ensure to store user-contact / display contact relations --- diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php index a3091f7d83..8c214a5c9b 100644 --- a/src/Model/Contact/User.php +++ b/src/Model/Contact/User.php @@ -27,7 +27,6 @@ use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\Database; use Friendica\Database\DBA; -use Friendica\Database\DBStructure; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\ItemURI; @@ -95,13 +94,14 @@ class User $update_fields = self::preparedFields($fields); if (!empty($update_fields)) { - $contacts = DBA::select('contact', ['uri-id', 'uid'], $condition); + $contacts = DBA::select('account-user-view', ['pid', 'uri-id', 'uid'], $condition); while ($contact = DBA::fetch($contacts)) { if (empty($contact['uri-id']) || empty($contact['uid'])) { continue; } - $ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']]); - Logger::info('Updated user contact', ['uid' => $contact['uid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]); + $update_fields['cid'] = $contact['pid']; + $ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true); + Logger::info('Updated user contact', ['uid' => $contact['uid'], 'id' => $contact['pid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]); } DBA::close($contacts); diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index d80405e235..a6aa2056f9 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -246,7 +246,7 @@ class Profile extends BaseModule $relation_text = ''; } - if (!in_array($contact['network'], array_merge(Protocol::FEDERATED, [Protocol::TWITTER]))) { + if (!Protocol::supportsFollow($contact['network'])) { $relation_text = ''; } diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index ffb66d9701..43dcd5ed29 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1518); + define('DB_UPDATE_VERSION', 1519); } return [ diff --git a/static/dbview.config.php b/static/dbview.config.php index 5e38acfd6c..b960cfaf3d 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -214,7 +214,7 @@ "parent-author-network" => ["parent-post-author", "network"], ], "query" => "FROM `post-user` - STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid` + INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid` STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id` STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id` STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id` @@ -763,7 +763,7 @@ "contact-type" => ["ownercontact", "contact-type"], ], "query" => "FROM `post-user` - STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid` + INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid` INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id` LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id` LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`