Continued:
- moved if() block to suggested position by MrPetovan, for me I want to have all conditions checked at the start of the method, e.g. no unwanted null references or (in this case) if the URL is blacklisted - normalized URLs are without SSL, means http://host/path/file.ext so they exist only once for contacts and servers (aka. instances) - documented returned type `void`
This commit is contained in:
parent
ba08692403
commit
27969e8ca6
|
@ -455,19 +455,12 @@ class GServer
|
|||
* Set failed server status
|
||||
*
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public static function setFailureByUrl(string $url)
|
||||
{
|
||||
$nurl = Strings::normaliseLink($url);
|
||||
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
Logger::info('Server domain is blocked', ['url' => $url]);
|
||||
return;
|
||||
} elseif (Network::isUrlBlocked($nurl)) {
|
||||
Logger::info('Server domain is blocked', ['nurl' => $nurl]);
|
||||
return;
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
||||
|
@ -481,6 +474,14 @@ class GServer
|
|||
return;
|
||||
}
|
||||
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
Logger::info('Server domain is blocked', ['url' => $url]);
|
||||
return;
|
||||
} elseif (Network::isUrlBlocked($nurl)) {
|
||||
Logger::info('Server domain is blocked', ['nurl' => $nurl]);
|
||||
return;
|
||||
}
|
||||
|
||||
self::insert(['url' => $url, 'nurl' => $nurl,
|
||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||
|
|
|
@ -63,7 +63,7 @@ class UpdateServerPeers
|
|||
}
|
||||
|
||||
++$total;
|
||||
if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink('https://' . $peer)])) {
|
||||
if (DBA::exists('gserver', ['nurl' => 'http://' . $peer])) {
|
||||
// We already know this server
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user