]> git.mxchange.org Git - friendica.git/commitdiff
Avoid locally probing last item via network
authorMichael <heluecht@pirati.ca>
Wed, 19 Aug 2020 04:45:31 +0000 (04:45 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 19 Aug 2020 04:45:31 +0000 (04:45 +0000)
src/Model/User.php
src/Network/Probe.php

index 38fe3b0ec4798c4826680218b3e4b7042dca2598..990df65dbd30f585bf83625cff5eaa3efd35ffcb 100644 (file)
@@ -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'];
index 137f2457553ba3c30f79c90766dfb883331a6396..99e62fb46640c096820d7608037a1c635324143e 100644 (file)
@@ -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;
                }