]> git.mxchange.org Git - friendica.git/commitdiff
Ensure *toArray returns an array
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 28 Jul 2019 04:03:42 +0000 (00:03 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 28 Jul 2019 04:03:42 +0000 (00:03 -0400)
src/Database/Database.php
src/Model/Attach.php
src/Model/Item.php

index 501d65fe76e660491cc14a872517d909dafe21fd..a2e31d89b5bdeb1cbc9be01ee8beb6208eef60fe 100644 (file)
@@ -1512,16 +1512,18 @@ class Database
        public function toArray($stmt, $do_close = true)
        {
                if (is_bool($stmt)) {
-                       return $stmt;
+                       return [];
                }
 
                $data = [];
                while ($row = $this->fetch($stmt)) {
                        $data[] = $row;
                }
+
                if ($do_close) {
                        $this->close($stmt);
                }
+
                return $data;
        }
 
index 758d3ae831c51ba112280a5f6fa49e8acd86e741..0073a6ed3f52f9b2ab6cddf8be1aad23aaa23858 100644 (file)
@@ -44,7 +44,7 @@ class Attach extends BaseObject
         * @param array $conditions Array of fields for conditions
         * @param array $params     Array of several parameters
         *
-        * @return boolean|array
+        * @return array
         *
         * @throws \Exception
         * @see   \Friendica\Database\DBA::selectToArray
@@ -55,7 +55,7 @@ class Attach extends BaseObject
                        $fields = self::getFields();
                }
 
-               $r = DBA::selectToArray('attach', $fields, $conditions, $params);
+               return DBA::selectToArray('attach', $fields, $conditions, $params);
        }
 
        /**
index c2bb6c892446bd9a76ec278c4524b3b4c9ae4374..c9d3e42693e3d73cb85a7d1ff47f4a9dd421caae 100644 (file)
@@ -383,16 +383,10 @@ class Item extends BaseObject
                $result = self::select($fields, $condition, $params);
 
                if (is_bool($result)) {
-                       return $result;
-               }
-
-               $data = [];
-               while ($row = self::fetch($result)) {
-                       $data[] = $row;
+                       return [];
                }
-               DBA::close($result);
 
-                return $data;
+        return DBA::toArray($result);
        }
 
        /**