]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #8803 from MrPetovan/bug/8477-api-photo-item-selectfirstforuser
authorMichael Vogel <icarus@dabo.de>
Thu, 25 Jun 2020 17:22:49 +0000 (19:22 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Jun 2020 17:22:49 +0000 (19:22 +0200)
[API] Replace unwarranted Item::selectFirstForUser calls in photo endpoints

src/Database/Database.php
src/Model/Profile.php
src/Module/Contact.php

index 806b2b86bbd73a48c3f4858fcb327544d742641e..897845ce0c8d6ba700c1a794d4149c99f0e1263c 100644 (file)
@@ -979,7 +979,7 @@ class Database
         * @return boolean was the insert successful?
         * @throws \Exception
         */
-       public function insert($table, $param, $on_duplicate_update = false)
+       public function insert($table, array $param, bool $on_duplicate_update = false)
        {
                if (empty($table) || empty($param)) {
                        $this->logger->info('Table and fields have to be set');
index 2b1546db49ef077eee04f0e763bf4a4a2532859e..2fcbde0779e8d98b72d0ff8b58c2ccd2f3fcf069 100644 (file)
@@ -258,7 +258,7 @@ class Profile
         * @hooks 'profile_sidebar'
         *      array $arr
         */
-       private static function sidebar(App $a, $profile, $block = 0, $show_connect = true)
+       private static function sidebar(App $a, array $profile, $block = 0, $show_connect = true)
        {
                $o = '';
                $location = false;
@@ -266,7 +266,8 @@ class Profile
                // This function can also use contact information in $profile
                $is_contact = !empty($profile['cid']);
 
-               if (!is_array($profile) && !count($profile)) {
+               if (empty($profile['nickname'])) {
+                       Logger::warning('Received profile with no nickname', ['profile' => $profile, 'callstack' => System::callstack(10)]);
                        return $o;
                }
 
@@ -291,8 +292,6 @@ class Profile
                $subscribe_feed_link = null;
                $wallmessage_link = null;
 
-
-
                $visitor_contact = [];
                if (!empty($profile['uid']) && self::getMyURL()) {
                        $visitor_contact = Contact::selectFirst(['rel'], ['uid' => $profile['uid'], 'nurl' => Strings::normaliseLink(self::getMyURL())]);
index 99a299b57129b0092b90ea9e007b95dee9337c1e..9f347154044f39334313aa57191b453c24c70d52 100644 (file)
@@ -714,15 +714,14 @@ class Contact extends BaseModule
                        $sql_values[] = $group;
                }
 
-               $sql_extra .= Widget::unavailableNetworks();
-
                $total = 0;
                $stmt = DBA::p("SELECT COUNT(*) AS `total`
                        FROM `contact`
                        WHERE `uid` = ?
                        AND `self` = 0
                        AND NOT `deleted`
-                       $sql_extra",
+                       $sql_extra
+                       " . Widget::unavailableNetworks(),
                        $sql_values
                );
                if (DBA::isResult($stmt)) {