diff --git a/src/Model/User.php b/src/Model/User.php index 38fe3b0ec4..990df65dbd 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -164,6 +164,11 @@ class User */ public static function getIdForURL(string $url) { + // Avoid any database requests when the hostname isn't even part of the url. + if (!strpos($url, DI::baseUrl()->getHostname())) { + return 0; + } + $self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]); if (!empty($self['uid'])) { return $self['uid']; diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 137f245755..99e62fb466 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -2012,6 +2012,14 @@ class Probe */ public static function getLastUpdate(array $data) { + $uid = User::getIdForURL($data['url']); + if (!empty($uid)) { + $contact = Contact::selectFirst(['url', 'last-item'], ['self' => true, 'uid' => $uid]); + if (!empty($contact['last-item'])) { + return $contact['last-item']; + } + } + if ($lastUpdate = self::updateFromNoScrape($data)) { return $lastUpdate; }