+ /**
+ * Checks if the given server array is unreachable for a long time now
+ *
+ * @param integer $gsid
+ * @return boolean
+ */
+ private static function isDefunct(array $gserver): bool
+ {
+ return ($gserver['failed'] || in_array($gserver['network'], Protocol::FEDERATED)) &&
+ ($gserver['last_contact'] >= $gserver['created']) &&
+ ($gserver['last_contact'] < $gserver['last_failure']) &&
+ ($gserver['last_contact'] < DateTimeFormat::utc('now - 90 days'));
+ }
+
+ /**
+ * Checks if the given server id is unreachable for a long time now
+ *
+ * @param integer $gsid
+ * @return boolean
+ */
+ public static function isDefunctById(int $gsid): bool
+ {
+ $gserver = DBA::selectFirst('gserver', ['url', 'next_contact', 'last_contact', 'last_failure', 'created', 'failed', 'network'], ['id' => $gsid]);
+ if (empty($gserver)) {
+ return false;
+ } else {
+ if (strtotime($gserver['next_contact']) < time()) {
+ UpdateGServer::add(Worker::PRIORITY_LOW, $gserver['url']);
+ }
+
+ return self::isDefunct($gserver);
+ }
+ }
+