Avoid locally probing last item via network

This commit is contained in:
Michael 2020-08-19 04:45:31 +00:00
parent 29494ea721
commit eb95314aaa
2 changed files with 13 additions and 0 deletions

View 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'];