Avoid locally probing last item via network
This commit is contained in:
parent
29494ea721
commit
eb95314aaa
|
@ -164,6 +164,11 @@ class User
|
||||||
*/
|
*/
|
||||||
public static function getIdForURL(string $url)
|
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)]);
|
$self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
|
||||||
if (!empty($self['uid'])) {
|
if (!empty($self['uid'])) {
|
||||||
return $self['uid'];
|
return $self['uid'];
|
||||||
|
|
|
@ -2012,6 +2012,14 @@ class Probe
|
||||||
*/
|
*/
|
||||||
public static function getLastUpdate(array $data)
|
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)) {
|
if ($lastUpdate = self::updateFromNoScrape($data)) {
|
||||||
return $lastUpdate;
|
return $lastUpdate;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue