]> git.mxchange.org Git - friendica.git/commitdiff
"Network::unparseURL" is replaced with "Uri::fromParts"
authorMichael <heluecht@pirati.ca>
Tue, 14 May 2024 21:47:57 +0000 (21:47 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 14 May 2024 21:47:57 +0000 (21:47 +0000)
src/Content/BoundariesPager.php
src/Content/ContactSelector.php
src/Content/Text/HTML.php
src/Model/PushSubscriber.php
src/Module/Api/Mastodon/Instance/Peers.php
src/Network/HTTPClient/Client/HttpClient.php
src/Network/HTTPClient/Response/CurlResult.php
src/Network/Probe.php
src/Util/Network.php

index 51838f053618bb66b8a7e7ca79ee4edc0a7a2403..76b387675e0d762aa2cb7f0cd09728aa57c9e5cf 100644 (file)
@@ -23,8 +23,8 @@ namespace Friendica\Content;
 
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
-use Friendica\Util\Network;
 use Friendica\Util\Strings;
+use GuzzleHttp\Psr7\Uri;
 
 /**
  * This pager should be used by lists using the min_id†/max_id† parameters
@@ -67,7 +67,7 @@ class BoundariesPager extends Pager
 
                        $parsed['query'] = http_build_query($queryParameters);
 
-                       $url = Network::unparseURL($parsed);
+                       $url = (string)Uri::fromParts((array)$parsed);
 
                        $this->setQueryString($url);
                }
index 1568e3a2fd3917c21974ed283ff2106a44d115b6..ed23151e60c4186c9a1f0fee6075d1450a8a89c0 100644 (file)
@@ -25,8 +25,8 @@ use Friendica\Core\Hook;
 use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Util\Network;
 use Friendica\Util\Strings;
+use GuzzleHttp\Psr7\Uri;
 
 /**
  * ContactSelector class
@@ -102,7 +102,7 @@ class ContactSelector
                        // Create the server url out of the profile url
                        $parts = parse_url($profile);
                        unset($parts['path']);
-                       $server_url = Strings::normaliseLink(Network::unparseURL($parts));
+                       $server_url = Strings::normaliseLink((string)Uri::fromParts((array)$parts));
                }
 
                self::$server_url[$profile] = $server_url;
index f3be678f9d49979ad794dea2a98fb1672cd02487..587c608de91297d69ea46ad4431851370fcc6860 100644 (file)
@@ -29,9 +29,9 @@ use Friendica\Core\Renderer;
 use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
+use GuzzleHttp\Psr7\Uri;
 use League\HTMLToMarkdown\HtmlConverter;
 use Psr\Http\Message\UriInterface;
 
@@ -407,7 +407,7 @@ class HTML
                }
 
                $parts = array_merge($base, parse_url($url));
-               $url2 = Network::unparseURL($parts);
+               $url2 = (string)Uri::fromParts((array)$parts);
 
                return str_replace($url, $url2, $link);
        }
index e910f2f1e11075604ebe22314a635a5009c2229d..42cb39596cfbe01555132e73d6375f6ce98b6251 100644 (file)
@@ -25,7 +25,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Network;
+use GuzzleHttp\Psr7\Uri;
 
 class PushSubscriber
 {
@@ -179,7 +179,7 @@ class PushSubscriber
 
                $parts = parse_url($subscriber['callback_url']);
                unset($parts['path']);
-               $server_url = Network::unparseURL($parts);
+               $server_url = (string)Uri::fromParts((array)$parts);
                $gsid = GServer::getID($server_url, true);
                if (!empty($gsid)) {
                        GServer::setProtocol($gsid, Post\DeliveryData::OSTATUS);
index 4bfde07c2d263a9841acf5921ff0915480a7f0c0..4c17791f5f4dd31a37b2a4b889d8f775761d4b9e 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Database\DBA;
 use Friendica\Model\GServer;
 use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException;
-use Friendica\Util\Network;
+use GuzzleHttp\Psr7\Uri;
 
 /**
  * Undocumented API endpoint that is implemented by both Mastodon and Pleroma
@@ -47,7 +47,7 @@ class Peers extends BaseApi
                while ($instance = DBA::fetch($instances)) {
                        $urldata = parse_url($instance['url']);
                        unset($urldata['scheme']);
-                       $return[] = ltrim(Network::unparseURL($urldata), '/');
+                       $return[] = ltrim((string)Uri::fromParts((array)$urldata), '/');
                }
                DBA::close($instances);
 
index f6669a20bf3435835f176bd7059ccdd242c19ef1..8613166a28c9c21e7828439ca3408072fa05d5dd 100644 (file)
@@ -33,6 +33,7 @@ use GuzzleHttp\Client;
 use GuzzleHttp\Cookie\FileCookieJar;
 use GuzzleHttp\Exception\RequestException;
 use GuzzleHttp\Exception\TransferException;
+use GuzzleHttp\Psr7\Uri;
 use GuzzleHttp\RequestOptions;
 use mattwright\URLResolver;
 use Psr\Http\Message\ResponseInterface;
@@ -104,7 +105,7 @@ class HttpClient implements ICanSendHttpRequests
                        }
                }
                $parts['path'] = implode('/', $parts2);
-               $url           = Network::unparseURL($parts);
+               $url           = (string)Uri::fromParts((array)$parts);
 
                if (Network::isUrlBlocked($url)) {
                        $this->logger->info('Domain is blocked.', ['url' => $url]);
index 561c8c47abfccab3a07b743e67c2fc16adb2f8ed..75d390eac7ad73491f75a31481b5e92f51d9b356 100644 (file)
 
 namespace Friendica\Network\HTTPClient\Response;
 
-use Friendica\Core\Logger;
 use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
 use Friendica\Network\HTTPException\UnprocessableEntityException;
-use Friendica\Util\Network;
+use GuzzleHttp\Psr7\Uri;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -224,7 +223,7 @@ class CurlResult implements ICanHandleHttpResponses
                                }
                        }
 
-                       $this->redirectUrl = Network::unparseURL($redirect_parts);
+                       $this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts);
 
                        $this->isRedirectUrl = true;
                } else {
index a0f1a85a47b16a8523dc07991f2cbc2b4884646a..77a25dac4b8685ee24dc038df60e26b0e7a94061 100644 (file)
@@ -1660,7 +1660,7 @@ class Probe
                unset($baseParts['query']);
                unset($baseParts['fragment']);
 
-               return Network::unparseURL((array)$baseParts);
+               return (string)Uri::fromParts((array)(array)$baseParts);
        }
 
        /**
index 54eb13bd1214347ede77ab0f1ca5cff638965645..fe376ce5c811b6f1acc90edf6c8e7c6480508966 100644 (file)
@@ -400,7 +400,7 @@ class Network
                ];
 
                $parts = array_merge($base, parse_url('/' . ltrim($url, '/')));
-               return self::unparseURL($parts);
+               return (string)Uri::fromParts((array)$parts);
        }
 
        /**
@@ -492,38 +492,6 @@ class Network
                return Strings::normaliseLink($match);
        }
 
-       /**
-        * Glue url parts together
-        *
-        * @param array $parsed URL parts
-        *
-        * @return string|null The glued URL or null on error
-        * @deprecated since version 2021.12, use GuzzleHttp\Psr7\Uri::fromParts($parts) instead
-        */
-       public static function unparseURL(array $parsed): string
-       {
-               $get = function ($key) use ($parsed) {
-                       return isset($parsed[$key]) ? $parsed[$key] : null;
-               };
-
-               $pass      = $get('pass');
-               $user      = $get('user');
-               $userinfo  = $pass !== null ? "$user:$pass" : $user;
-               $port      = $get('port');
-               $scheme    = $get('scheme');
-               $query     = $get('query');
-               $fragment  = $get('fragment');
-               $authority = ($userinfo !== null ? $userinfo . '@' : '') .
-                                               $get('host') .
-                                               ($port ? ":$port" : '');
-
-               return  (!empty($scheme) ? $scheme . ':' : '') .
-                       (!empty($authority) ? '//' . $authority : '') .
-                       $get('path') .
-                       (!empty($query) ? '?' . $query : '') .
-                       (!empty($fragment) ? '#' . $fragment : '');
-       }
-
        /**
         * Convert an URI to an IDN compatible URI
         *
@@ -602,7 +570,7 @@ class Network
 
                $parsed['query'] = http_build_query($params);
 
-               return self::unparseURL($parsed);
+               return (string)Uri::fromParts((array)$parsed);
        }
 
        /**