]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
Update function / rearrange tab order
[friendica.git] / src / Util / ParseUrl.php
index 9d19a4ebac9e02aade552216f4bbfc23f9727f21..79f427a654df4b5f672bc52f3470ebe01deb2b5b 100644 (file)
@@ -70,7 +70,12 @@ class ParseUrl
                        $options = [];
                }
 
-               $curlResult = DI::httpClient()->head($url, array_merge([HttpClientOptions::ACCEPT_CONTENT => $accept], $options));
+               try {
+                       $curlResult = DI::httpClient()->head($url, array_merge([HttpClientOptions::ACCEPT_CONTENT => $accept], $options));
+               } catch (\Exception $e) {
+                       DI::logger()->debug('Got exception', ['url' => $url, 'message' => $e->getMessage()]);
+                       return [];
+               }
 
                // Workaround for systems that can't handle a HEAD request. Don't retry on timeouts.
                if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() >= 400) && !in_array($curlResult->getReturnCode(), [408, 504])) {
@@ -91,7 +96,7 @@ class ParseUrl
        }
 
        /**
-        * Search for chached embeddable data of an url otherwise fetch it
+        * Search for cached embeddable data of an url otherwise fetch it
         *
         * @param string $url         The url of the page which should be scraped
         * @param bool   $do_oembed   The false option is used by the function fetch_oembed()
@@ -646,7 +651,7 @@ class ParseUrl
                $arr_tags = str_getcsv($string);
                if (count($arr_tags)) {
                        // add the # sign to every tag
-                       array_walk($arr_tags, ['self', 'arrAddHashes']);
+                       array_walk($arr_tags, [self::class, 'arrAddHashes']);
 
                        return $arr_tags;
                }
@@ -686,7 +691,7 @@ class ParseUrl
        {
                $urlarr = parse_url($url);
 
-               // If the url does allready have an scheme
+               // If the url does already have an scheme
                // we can stop the process here
                if (isset($urlarr['scheme'])) {
                        return $url;