]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #9436 from nupplaphil/task/test_notices
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 19 Oct 2020 11:26:16 +0000 (07:26 -0400)
committerGitHub <noreply@github.com>
Mon, 19 Oct 2020 11:26:16 +0000 (07:26 -0400)
Fix notices/deprecation notes/wrong calls in "test" directory

17 files changed:
mod/parse_url.php
src/Content/OEmbed.php
src/Content/Text/BBCode.php
src/Core/Search.php
src/Core/Worker.php
src/Model/GServer.php
src/Model/Photo.php
src/Model/User.php
src/Module/Conversation/Network.php
src/Module/Magic.php
src/Network/HTTPRequest.php
src/Network/IHTTPRequest.php
src/Network/Probe.php
src/Protocol/OStatus.php
src/Util/HTTPSignature.php
src/Util/Images.php
src/Worker/OnePoll.php

index a1faab6efb6d07c82bc5e49d5f3bdc8bfbfbc910..ede557ff225dd1e74768ef8094b42b5b44aa65f4 100644 (file)
@@ -85,7 +85,7 @@ function parse_url_content(App $a)
        // Check if the URL is an image, video or audio file. If so format
        // the URL with the corresponding BBCode media tag
        // Fetch the header of the URL
-       $curlResponse = DI::httpRequest()->get($url, false, ['novalidate' => true, 'nobody' => true]);
+       $curlResponse = DI::httpRequest()->get($url, ['novalidate' => true, 'nobody' => true]);
 
        if ($curlResponse->isSuccess()) {
                // Convert the header fields into an array
index 30a113f461414b336fc37dafa3ef0af345aa0204..4233a2aad707a9fb6240cd35b19446324f5e0b02 100644 (file)
@@ -95,7 +95,7 @@ class OEmbed
 
                        if (!in_array($ext, $noexts)) {
                                // try oembed autodiscovery
-                               $html_text = DI::httpRequest()->fetch($embedurl, false, 15, 'text/*');
+                               $html_text = DI::httpRequest()->fetch($embedurl, 15, 'text/*');
                                if ($html_text) {
                                        $dom = @DOMDocument::loadHTML($html_text);
                                        if ($dom) {
index 594cd9a6ce479ba578b1878740e2cf968c7ee2a1..e241abadc89b6efb9b83a0271354a84575c36dac 100644 (file)
@@ -485,7 +485,7 @@ class BBCode
                                        continue;
                                }
 
-                               $curlResult = DI::httpRequest()->get($mtch[1], true);
+                               $curlResult = DI::httpRequest()->get($mtch[1]);
                                if (!$curlResult->isSuccess()) {
                                        continue;
                                }
index 7f9ffeec5da0943397050ae4f99e8e5df8c7b793..aedad2f0e15f28fd470efccd67c67f5e88a373dc 100644 (file)
@@ -122,7 +122,7 @@ class Search
                        $searchUrl .= '&page=' . $page;
                }
 
-               $resultJson = DI::httpRequest()->fetch($searchUrl, false, 0, 'application/json');
+               $resultJson = DI::httpRequest()->fetch($searchUrl, 0, 'application/json');
 
                $results = json_decode($resultJson, true);
 
@@ -264,7 +264,7 @@ class Search
                        $return = Contact::searchByName($search, $mode);
                } else {
                        $p = $page > 1 ? 'p=' . $page : '';
-                       $curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
+                       $curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), ['accept_content' => 'application/json']);
                        if ($curlResult->isSuccess()) {
                                $searchResult = json_decode($curlResult->getBody(), true);
                                if (!empty($searchResult['profiles'])) {
index 09cf14e5af4e5afb1d6d039c78469f075a139f87..9af219e4760cb1b907f8e12bc7f0c1ca1bf775ae 100644 (file)
@@ -1064,7 +1064,7 @@ class Worker
                }
 
                $url = DI::baseUrl() . '/worker';
-               DI::httpRequest()->fetch($url, false, 1);
+               DI::httpRequest()->fetch($url, 1);
        }
 
        /**
index 323a23f494522749263d46abb5b4d5194311a93d..009816d8186c7f82f1b71a4b007de7f99fa39f5c 100644 (file)
@@ -311,7 +311,7 @@ class GServer
 
                // When a nodeinfo is present, we don't need to dig further
                $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
-               $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
+               $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', ['timeout' => $xrd_timeout]);
                if ($curlResult->isTimeout()) {
                        self::setFailure($url);
                        return false;
@@ -344,7 +344,7 @@ class GServer
                                        $basedata = ['detection-method' => self::DETECT_MANUAL];
                                }
 
-                               $curlResult = DI::httpRequest()->get($baseurl, false, ['timeout' => $xrd_timeout]);
+                               $curlResult = DI::httpRequest()->get($baseurl, ['timeout' => $xrd_timeout]);
                                if ($curlResult->isSuccess()) {
                                        $basedata = self::analyseRootHeader($curlResult, $basedata);
                                        $basedata = self::analyseRootBody($curlResult, $basedata, $baseurl);
@@ -361,7 +361,7 @@ class GServer
                                        // When the base path doesn't seem to contain a social network we try the complete path.
                                        // Most detectable system have to be installed in the root directory.
                                        // We checked the base to avoid false positives.
-                                       $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout]);
+                                       $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout]);
                                        if ($curlResult->isSuccess()) {
                                                $urldata = self::analyseRootHeader($curlResult, $serverdata);
                                                $urldata = self::analyseRootBody($curlResult, $urldata, $url);
@@ -913,7 +913,7 @@ class GServer
        private static function validHostMeta(string $url)
        {
                $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
-               $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
+               $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', ['timeout' => $xrd_timeout]);
                if (!$curlResult->isSuccess()) {
                        return false;
                }
@@ -1639,7 +1639,7 @@ class GServer
                if (!empty($accesstoken)) {
                        $api = 'https://instances.social/api/1.0/instances/list?count=0';
                        $header = ['Authorization: Bearer '.$accesstoken];
-                       $curlResult = DI::httpRequest()->get($api, false, ['headers' => $header]);
+                       $curlResult = DI::httpRequest()->get($api, ['headers' => $header]);
 
                        if ($curlResult->isSuccess()) {
                                $servers = json_decode($curlResult->getBody(), true);
index 6380f42789d734bf0f454457e670565fb6a65681..db63f6c596d8856190cea483eb5c2ac6298b6eec 100644 (file)
@@ -422,7 +422,7 @@ class Photo
 
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpRequest()->get($image_url, true);
+                       $ret = DI::httpRequest()->get($image_url);
                        $img_str = $ret->getBody();
                        $type = $ret->getContentType();
                } else {
index 68c42e40e093f2d3c9219609d06f626eb101c3d9..eda724efc7e4df81a4e6fae7f69a9e85470ed443 100644 (file)
@@ -1002,7 +1002,7 @@ class User
                        $photo_failure = false;
 
                        $filename = basename($photo);
-                       $curlResult = DI::httpRequest()->get($photo, true);
+                       $curlResult = DI::httpRequest()->get($photo);
                        if ($curlResult->isSuccess()) {
                                $img_str = $curlResult->getBody();
                                $type = $curlResult->getContentType();
index f21b3816a6848cf5111824816331a251a3fd59e0..abe836f27a56f9809daca7f8ec699cde31505b95 100644 (file)
@@ -11,6 +11,7 @@ use Friendica\Content\Text\HTML;
 use Friendica\Core\ACL;
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -282,7 +283,7 @@ class Network extends BaseModule
 
                self::$forumContactId = $parameters['contact_id'] ?? 0;
 
-               self::$selectedTab = DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', '');
+               self::$selectedTab = Session::get('network-tab', '');
 
                if (!empty($get['star'])) {
                        self::$selectedTab = 'star';
@@ -296,13 +297,18 @@ class Network extends BaseModule
                        self::$selectedTab = $get['order'];
                }
 
-               DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab);
+               Session::set('network-tab', self::$selectedTab);
 
-               self::$star    = intval($get['star']      ?? 0);
-               self::$mention = intval($_GET['mention']      ?? 0);
-               self::$order   = in_array(self::$selectedTab, ['received', 'commented', 'created', 'uriid']) ? self::$selectedTab : 'commented';
+               self::$star    = intval($get['star'] ?? 0);
+               self::$mention = intval($get['mention'] ?? 0);
+               self::$order   = $get['order'] ?? Session::get('network-order', 'commented');
 
-               self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? '';
+               self::$selectedTab = self::$selectedTab ?? self::$order;
+
+               Session::set('network-tab', self::$selectedTab);
+               Session::set('network-order', self::$order);
+
+               self::$accountTypeString = $get['accounttype'] ?? $parameters['accounttype'] ?? '';
                self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
 
                self::$network = $get['nets'] ?? '';
@@ -318,21 +324,21 @@ class Network extends BaseModule
                                DI::config()->get('system', 'itemspage_network'));
                }
 
-               self::$min_id = $_GET['min_id'] ?? null;
-               self::$max_id = $_GET['max_id'] ?? null;
+               self::$min_id = $get['min_id'] ?? null;
+               self::$max_id = $get['max_id'] ?? null;
 
-               switch (self::$selectedTab) {
+               switch (self::$order) {
                        case 'received':
-                               self::$max_id = $_GET['last_received'] ?? self::$max_id;
+                               self::$max_id = $get['last_received'] ?? self::$max_id;
                                break;
                        case 'commented':
-                               self::$max_id = $_GET['last_commented'] ?? self::$max_id;
+                               self::$max_id = $get['last_commented'] ?? self::$max_id;
                                break;
                        case 'created':
-                               self::$max_id = $_GET['last_created'] ?? self::$max_id;
+                               self::$max_id = $get['last_created'] ?? self::$max_id;
                                break;
                        case 'uriid':
-                               self::$max_id = $_GET['last_uriid'] ?? self::$max_id;
+                               self::$max_id = $get['last_uriid'] ?? self::$max_id;
                                break;
                }
        }
@@ -420,26 +426,20 @@ class Network extends BaseModule
                        $items = array_reverse($items);
                }
 
-               $parents_str = '';
                if (DBA::isResult($items)) {
-                       $parents_arr = [];
-
-                       foreach ($items as $item) {
-                               if (!in_array($item['parent'], $parents_arr) && ($item['parent'] > 0)) {
-                                       $parents_arr[] = $item['parent'];
-                               }
-                       }
-                       $parents_str = implode(', ', $parents_arr);
+                       $parents = array_column($items, 'parent');
+               } else {
+                       $parents = [];
                }
 
                // We aren't going to try and figure out at the item, group, and page
                // level which items you've seen and which you haven't. If you're looking
                // at the top level network page just mark everything seen.
-               if (!self::$groupId && !self::$forumContactId && self::$selectedTab != 'star') {
+               if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
                        $condition = ['unseen' => true, 'uid' => local_user()];
                        self::setItemsSeenByCondition($condition);
-               } elseif ($parents_str) {
-                       $condition = ["`uid` = ? AND `unseen` AND `parent` IN (" . DBA::escape($parents_str) . ")", local_user()];
+               } elseif (!empty($parents)) {
+                       $condition = ['unseen' => true, 'uid' => local_user(), 'parent' => $parents];
                        self::setItemsSeenByCondition($condition);
                }
 
index 95b742bb301b9ec3c7f1621779f4415aede7aaa1..fc37d91b4574f3069aa9359675b74eefde82629c 100644 (file)
@@ -100,7 +100,7 @@ class Magic extends BaseModule
                                );
 
                                // Try to get an authentication token from the other instance.
-                               $curlResult = DI::httpRequest()->get($basepath . '/owa', false, ['headers' => $headers]);
+                               $curlResult = DI::httpRequest()->get($basepath . '/owa', ['headers' => $headers]);
 
                                if ($curlResult->isSuccess()) {
                                        $j = json_decode($curlResult->getBody(), true);
index e4ff041039ed8ba225022000faa6af8f2c159af7..6442295273857e7af78df608b614f9e97e30fa22 100644 (file)
@@ -59,7 +59,7 @@ class HTTPRequest implements IHTTPRequest
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function get(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
+       public function get(string $url, array $opts = [], int &$redirects = 0)
        {
                $stamp1 = microtime(true);
 
@@ -172,12 +172,7 @@ class HTTPRequest implements IHTTPRequest
                        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
                }
 
-               if ($binary) {
-                       @curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
-               }
-
-               // don't let curl abort the entire application
-               // if it throws any errors.
+               $logger = $this->logger;
 
                $s         = @curl_exec($ch);
                $curl_info = @curl_getinfo($ch);
@@ -196,7 +191,7 @@ class HTTPRequest implements IHTTPRequest
                        $redirects++;
                        $this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
                        @curl_close($ch);
-                       return $this->get($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
+                       return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects);
                }
 
                @curl_close($ch);
@@ -435,9 +430,9 @@ class HTTPRequest implements IHTTPRequest
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+       public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
        {
-               $ret = $this->fetchFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
+               $ret = $this->fetchFull($url, $timeout, $accept_content, $cookiejar, $redirects);
 
                return $ret->getBody();
        }
@@ -449,11 +444,10 @@ class HTTPRequest implements IHTTPRequest
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+       public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
        {
                return $this->get(
                        $url,
-                       $binary,
                        [
                                'timeout'        => $timeout,
                                'accept_content' => $accept_content,
index 3ebcc5dc1bc6316e01f0af50085d4ed901f09452..d6bf9810528d42cd95b8879327ef76be88b7033f 100644 (file)
@@ -34,7 +34,6 @@ interface IHTTPRequest
         * to preserve cookies from one request to the next.
         *
         * @param string $url             URL to fetch
-        * @param bool   $binary          default false
         *                                TRUE if asked to return binary results (file download)
         * @param int    $timeout         Timeout in seconds, default system config value or 60 seconds
         * @param string $accept_content  supply Accept: header with 'accept_content' as the value
@@ -42,7 +41,7 @@ interface IHTTPRequest
         *
         * @return string The fetched content
         */
-       public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
+       public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
 
        /**
         * Fetches the whole response of an URL.
@@ -51,7 +50,6 @@ interface IHTTPRequest
         * all the information collected during the fetch.
         *
         * @param string $url             URL to fetch
-        * @param bool   $binary          default false
         *                                TRUE if asked to return binary results (file download)
         * @param int    $timeout         Timeout in seconds, default system config value or 60 seconds
         * @param string $accept_content  supply Accept: header with 'accept_content' as the value
@@ -59,13 +57,12 @@ interface IHTTPRequest
         *
         * @return CurlResult With all relevant information, 'body' contains the actual fetched content.
         */
-       public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
+       public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
 
        /**
         * Send a GET to an URL.
         *
         * @param string $url        URL to fetch
-        * @param bool   $binary     default false
         *                           TRUE if asked to return binary results (file download)
         * @param array  $opts       (optional parameters) assoziative array with:
         *                           'accept_content' => supply Accept: header with 'accept_content' as the value
@@ -78,7 +75,7 @@ interface IHTTPRequest
         *
         * @return CurlResult
         */
-       public function get(string $url, bool $binary = false, array $opts = []);
+       public function get(string $url, array $opts = []);
 
        /**
         * Send POST request to an URL
index 3fe035286f3bed729a11b947d06ac3eb551d063b..67db29a4f3536fe9b0e98332de9578ac55db8b8a 100644 (file)
@@ -169,7 +169,7 @@ class Probe
                Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
                $xrd = null;
 
-               $curlResult = DI::httpRequest()->get($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+               $curlResult = DI::httpRequest()->get($ssl_url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
                $ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                if ($curlResult->isSuccess()) {
                        $xml = $curlResult->getBody();
@@ -186,7 +186,7 @@ class Probe
                }
 
                if (!is_object($xrd) && !empty($url)) {
-                       $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+                       $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
                        $connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                        if ($curlResult->isTimeout()) {
                                Logger::info('Probing timeout', ['url' => $url]);
@@ -941,7 +941,7 @@ class Probe
        {
                $xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
 
-               $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
+               $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
index 0635be87d1c9a83191d80ac0bed7d349b06ed577..4b67d8ecb292a5790431ab15adef27b437ec1493 100644 (file)
@@ -738,7 +738,7 @@ class OStatus
 
                self::$conv_list[$conversation] = true;
 
-               $curlResult = DI::httpRequest()->get($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
+               $curlResult = DI::httpRequest()->get($conversation, ['accept_content' => 'application/atom+xml, text/html']);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -931,7 +931,7 @@ class OStatus
                }
 
                $stored = false;
-               $curlResult = DI::httpRequest()->get($related, false, ['accept_content' => 'application/atom+xml, text/html']);
+               $curlResult = DI::httpRequest()->get($related, ['accept_content' => 'application/atom+xml, text/html']);
 
                if (!$curlResult->isSuccess()) {
                        return;
index cdee48bfc02683bb5e67f31cfc1ba9e26240bec6..e3ed5d07995b7e9a641a9e80878112d0e5b146ab 100644 (file)
@@ -449,7 +449,7 @@ class HTTPSignature
                $curl_opts = $opts;
                $curl_opts['header'] = $headers;
 
-               $curlResult = DI::httpRequest()->get($request, false, $curl_opts);
+               $curlResult = DI::httpRequest()->get($request, $curl_opts);
                $return_code = $curlResult->getReturnCode();
 
                Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG);
index f39b0db00dc235a643475159e562724bc4c0c0b6..612a21ed54dc14933be90be9dc1e3fb732c025b0 100644 (file)
@@ -184,7 +184,7 @@ class Images
                        return $data;
                }
 
-               $img_str = DI::httpRequest()->fetch($url, true, 4);
+               $img_str = DI::httpRequest()->fetch($url, 4);
 
                if (!$img_str) {
                        return [];
index 5fc65b211a1d4f4414d896c64ef1d64c5f737f97..93dff93ae5a8d1fe4aa1109349e48226809cdde8 100644 (file)
@@ -444,7 +444,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
-               $curlResult = DI::httpRequest()->get($contact['poll'], false, ['cookiejar' => $cookiejar]);
+               $curlResult = DI::httpRequest()->get($contact['poll'], ['cookiejar' => $cookiejar]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {