From 41678ec3cd24fadb5fa0649694f29b4dced0e75a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 1 Mar 2018 19:54:45 -0500 Subject: [PATCH] Add no_update flag to speed up Contact::getIdForURL instances --- boot.php | 4 ++-- src/Content/Text/BBCode.php | 2 +- src/Content/Widget.php | 2 +- src/Model/Item.php | 2 +- src/Protocol/OStatus.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/boot.php b/boot.php index 472814a6db..4ba8c1ad8d 100644 --- a/boot.php +++ b/boot.php @@ -925,10 +925,10 @@ function public_contact() if (!$public_contact_id && x($_SESSION, 'authenticated')) { if (x($_SESSION, 'my_address')) { // Local user - $public_contact_id = intval(Contact::getIdForURL($_SESSION['my_address'], 0)); + $public_contact_id = intval(Contact::getIdForURL($_SESSION['my_address'], 0, true)); } elseif (x($_SESSION, 'visitor_home')) { // Remote user - $public_contact_id = intval(Contact::getIdForURL($_SESSION['visitor_home'], 0)); + $public_contact_id = intval(Contact::getIdForURL($_SESSION['visitor_home'], 0, true)); } } elseif (!x($_SESSION, 'authenticated')) { $public_contact_id = false; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 9f250e9bfa..8dd9305ca3 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1077,7 +1077,7 @@ class BBCode // We only call this so that a previously unknown contact can be added. // This is important for the function "Model\Contact::getDetailsByURL()". // This function then can fetch an entry from the contact table. - Contact::getIdForURL($profile, 0); + Contact::getIdForURL($profile, 0, true); $data = Contact::getDetailsByURL($profile); diff --git a/src/Content/Widget.php b/src/Content/Widget.php index d257242985..058a7a1fb5 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -330,7 +330,7 @@ class Widget } if (Feature::isEnabled($a->profile['profile_uid'], 'tagadelic')) { - $owner_id = Contact::getIdForURL($a->profile['url']); + $owner_id = Contact::getIdForURL($a->profile['url'], 0, true); if (!$owner_id) { return ''; diff --git a/src/Model/Item.php b/src/Model/Item.php index 926552a17e..d6257d99a1 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1723,7 +1723,7 @@ class Item extends BaseObject $item_contact_id = $owner_self_contact['id']; $item_contact = $owner_self_contact; } else { - $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid); + $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true); $item_contact = dba::selectFirst('contact', [], ['id' => $item_contact_id]); if (!DBM::is_result($item_contact)) { logger('like: unknown item contact ' . $item_contact_id); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index a3fdacf331..c6f840a66e 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -186,7 +186,7 @@ class OStatus } // Ensure that we are having this contact (with uid=0) - $cid = Contact::getIdForURL($aliaslink, 0); + $cid = Contact::getIdForURL($aliaslink, 0, true); if ($cid) { $fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location']; @@ -2108,7 +2108,7 @@ class OStatus } $check_date = DateTimeFormat::utc($last_update); - $authorid = Contact::getIdForURL($owner["url"], 0); + $authorid = Contact::getIdForURL($owner["url"], 0, true); $sql_extra = ''; if ($filter === 'posts') {