]> git.mxchange.org Git - friendica.git/commitdiff
Ensure Post::toArray returns an array
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 14 Nov 2022 19:53:54 +0000 (14:53 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 14 Nov 2022 19:53:54 +0000 (14:53 -0500)
- We don't handle query errors anyway
- Remove unused parameter do_close
- Address https://github.com/friendica/friendica/issues/11993#issuecomment-1314245581

src/Model/Post.php

index 635a84efd6fbc7ac4625af896e170ddb5dc2f571..11e5c2c985a8e0e4301a06cbd09bebe01a7a912b 100644 (file)
@@ -102,26 +102,25 @@ class Post
        }
 
        /**
-        * Fills an array with data from an post query
+        * Fills an array with data from a post query
         *
-        * @param object $stmt statement object
-        * @param bool   $do_close
+        * @param object|bool $stmt Return value from Database->select
         * @return array Data array
-        * @todo Find proper type-hint for $stmt and maybe avoid boolean
+        * @throws \Exception
         */
-       public static function toArray($stmt, bool $do_close = true)
+       public static function toArray($stmt): array
        {
                if (is_bool($stmt)) {
-                       return $stmt;
+                       return [];
                }
 
                $data = [];
                while ($row = self::fetch($stmt)) {
                        $data[] = $row;
                }
-               if ($do_close) {
-                       DBA::close($stmt);
-               }
+
+               DBA::close($stmt);
+
                return $data;
        }