]> git.mxchange.org Git - friendica.git/commitdiff
fix more errors
authorArt4 <art4@wlabs.de>
Sun, 17 Nov 2024 22:13:01 +0000 (22:13 +0000)
committerArt4 <art4@wlabs.de>
Sun, 17 Nov 2024 22:13:01 +0000 (22:13 +0000)
src/Network/Probe.php
src/Protocol/Email.php
src/Worker/OnePoll.php

index 99fb9ed2112ab2db63b042419e9b53abdc80a0ca..ca2351afafda5e9a79d68ede002cb6ae2ea2a4d8 100644 (file)
@@ -220,14 +220,16 @@ class Probe
                        Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
                        return [];
                }
+
                $ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
+
+               $host_url = $host;
+
                if ($curlResult->isSuccess()) {
                        $xml = $curlResult->getBodyString();
                        $xrd = XML::parseString($xml, true);
                        if (!empty($url)) {
                                $host_url = 'https://' . $host;
-                       } else {
-                               $host_url = $host;
                        }
                } elseif ($curlResult->isTimeout()) {
                        Logger::info('Probing timeout', ['url' => $ssl_url]);
@@ -550,6 +552,7 @@ class Probe
        public static function getWebfingerArray(string $uri): array
        {
                $parts = parse_url($uri);
+               $lrdd  = [];
 
                if (!empty($parts['scheme']) && !empty($parts['host'])) {
                        $host = $parts['host'];
@@ -563,7 +566,7 @@ class Probe
                        $addr = '';
 
                        $path_parts = explode('/', trim($parts['path'] ?? '', '/'));
-                       if (!empty($path_parts)) {
+                       if (is_array($path_parts)) {
                                $nick = ltrim(end($path_parts), '@');
                                $addr = $nick . '@' . $host;
                        }
@@ -668,8 +671,10 @@ class Probe
                        return null;
                }
 
+               $detected = '';
+
                // First try the address because this is the primary purpose of webfinger
-               if (!empty($addr)) {
+               if ($addr !== '') {
                        $detected = $addr;
                        $path = str_replace('{uri}', urlencode('acct:' . $addr), $template);
                        $webfinger = self::webfinger($path, $type);
@@ -823,13 +828,15 @@ class Probe
         */
        private static function zot(array $webfinger, array $data): array
        {
+               $zot_url = '';
+
                foreach ($webfinger['links'] as $link) {
                        if (($link['rel'] == 'http://purl.org/zot/protocol/6.0') && !empty($link['href'])) {
                                $zot_url = $link['href'];
                        }
                }
 
-               if (empty($zot_url)) {
+               if ($zot_url === '') {
                        return $data;
                }
 
@@ -871,7 +878,7 @@ class Probe
                                $data['url'] = $link['href'];
                        }
                }
-               
+
                $data = self::pollZot($zot_url, $data);
 
                if (!empty($data['url']) && !empty($webfinger['aliases']) && is_array($webfinger['aliases'])) {
@@ -1429,7 +1436,7 @@ class Probe
                        && !empty($data['guid'])
                        && !empty($data['baseurl'])
                        && !empty($data['pubkey'])
-                       && !empty($hcard_url)
+                       && $hcard_url !== ''
                ) {
                        $data['network'] = Protocol::DIASPORA;
                        $data['manually-approve'] = false;
@@ -1776,7 +1783,7 @@ class Probe
                $password = '';
                openssl_private_decrypt(hex2bin($mailacct['pass']), $password, $user['prvkey']);
                $mbox = Email::connect($mailbox, $mailacct['user'], $password);
-               if (!$mbox) {
+               if ($mbox === false) {
                        return [];
                }
 
@@ -1828,7 +1835,7 @@ class Probe
                        }
                }
 
-               if (!empty($mbox)) {
+               if ($mbox !== false) {
                        imap_close($mbox);
                }
 
index 0c83a910890c7a573b2764add280228231a96e04..765a474773d5b5ba8be15c1ed2f31d8d1c75029e 100644 (file)
@@ -25,7 +25,7 @@ class Email
         * @param string $mailbox  The mailbox name
         * @param string $username The username
         * @param string $password The password
-        * @return Connection|resource|bool
+        * @return Connection|false
         * @throws \Exception
         */
        public static function connect(string $mailbox, string $username, string $password)
index c7b704bf636491fd71d400a7a0f02428762b7a83..c9b16717b7e48c931713413d9feccee8ef08c2c2 100644 (file)
@@ -220,7 +220,7 @@ class OnePoll
 
                Logger::info('Mail is enabled');
 
-               $mbox = null;
+               $mbox = false;
                $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]);
 
                $condition = ["`server` != ? AND `user` != ? AND `port` != ? AND `uid` = ?", '', '', 0, $importer_uid];
@@ -232,17 +232,18 @@ class OnePoll
                        $mbox = Email::connect($mailbox, $mailconf['user'], $password);
                        unset($password);
                        Logger::notice('Connect', ['user' => $mailconf['user']]);
-                       if ($mbox) {
-                               $fields = ['last_check' => $updated];
-                               DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
-                               Logger::notice('Connected', ['user' => $mailconf['user']]);
-                       } else {
+
+                       if ($mbox === false) {
                                Logger::notice('Connection error', ['user' => $mailconf['user'], 'error' => imap_errors()]);
                                return false;
                        }
+
+                       $fields = ['last_check' => $updated];
+                       DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
+                       Logger::notice('Connected', ['user' => $mailconf['user']]);
                }
 
-               if (empty($mbox)) {
+               if ($mbox === false) {
                        return false;
                }