]> git.mxchange.org Git - friendica.git/commitdiff
Wrap HTTP client call in try catch in Network\Probe
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 May 2023 04:26:16 +0000 (00:26 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 May 2023 04:26:16 +0000 (00:26 -0400)
- Address https://github.com/friendica/friendica/issues/13023#issuecomment-1521458475

src/Network/Probe.php

index d344d556c3ff19f2b8908d8bd609c4cb6f978f87..b1931ae6d36bb6d5cbf8b43bd693cf92ae3024ba 100644 (file)
@@ -952,9 +952,17 @@ class Probe
         */
        public static function webfinger(string $url, string $type): array
        {
-               $xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
+               try {
+                       $curlResult = DI::httpClient()->get(
+                               $url,
+                               $type,
+                               [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout', 20)]
+                       );
+               } catch (\Throwable $e) {
+                       Logger::notice($e->getMessage(), ['url' => $url, 'type' => $type, 'class' => get_class($e)]);
+                       return [];
+               }
 
-               $curlResult = DI::httpClient()->get($url, $type, [HttpClientOptions::TIMEOUT => $xrd_timeout]);
                if ($curlResult->isTimeout()) {
                        self::$isTimeout = true;
                        return [];