Rename DBA::inArray to DBA::toArray
authorHypolite Petovan <mrpetovan@gmail.com>
Sat, 21 Jul 2018 02:03:40 +0000 (22:03 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Sun, 22 Jul 2018 23:27:35 +0000 (19:27 -0400)
17 files changed:
include/dba.php
include/security.php
mod/admin.php
mod/community.php
mod/network.php
src/Content/ContactSelector.php
src/Core/ACL.php
src/Core/Addon.php
src/Core/Worker.php
src/Database/DBA.php
src/Model/Contact.php
src/Model/Event.php
src/Model/Group.php
src/Model/Profile.php
src/Network/FKOAuthDataStore.php
src/Worker/Notifier.php
src/Worker/Queue.php

index 32d3b1d..bccd979 100644 (file)
@@ -41,7 +41,7 @@ function q($sql) {
 
        $columns = DBA::columnCount($ret);
 
-       $data = DBA::inArray($ret);
+       $data = DBA::toArray($ret);
 
        if ((count($data) == 0) && ($columns == 0)) {
                return true;
index 987f3b0..53e554c 100644 (file)
@@ -116,7 +116,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                $r = DBA::select('user', ['uid', 'username', 'nickname'],
                        ['parent-uid' => $master_record['uid'], 'account_removed' => false]);
                if (DBM::is_result($r)) {
-                       $a->identities = array_merge($a->identities, DBA::inArray($r));
+                       $a->identities = array_merge($a->identities, DBA::toArray($r));
                }
        } else {
                // Just ensure that the array is always defined
@@ -126,14 +126,14 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                $r = DBA::select('user', ['uid', 'username', 'nickname'],
                        ['uid' => $master_record['parent-uid'], 'account_removed' => false]);
                if (DBM::is_result($r)) {
-                       $a->identities = DBA::inArray($r);
+                       $a->identities = DBA::toArray($r);
                }
 
                // Then add all siblings
                $r = DBA::select('user', ['uid', 'username', 'nickname'],
                        ['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
                if (DBM::is_result($r)) {
-                       $a->identities = array_merge($a->identities, DBA::inArray($r));
+                       $a->identities = array_merge($a->identities, DBA::toArray($r));
                }
        }
 
@@ -144,7 +144,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                $master_record['uid']
        );
        if (DBM::is_result($r)) {
-               $a->identities = array_merge($a->identities, DBA::inArray($r));
+               $a->identities = array_merge($a->identities, DBA::toArray($r));
        }
 
        if ($login_initial) {
index a6a0911..7c465fe 100644 (file)
@@ -479,7 +479,7 @@ function admin_page_contactblock(App $a)
 
        $statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
 
-       $contacts = DBA::inArray($statement);
+       $contacts = DBA::toArray($statement);
 
        $t = get_markup_template('admin/contactblock.tpl');
        $o = replace_macros($t, [
@@ -782,7 +782,7 @@ function admin_page_workerqueue(App $a)
 {
        // get jobs from the workerqueue table
        $statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
-       $r = DBA::inArray($statement);
+       $r = DBA::toArray($statement);
 
        for($i = 0; $i < count($r); $i++) {
                $r[$i]['parameter'] = implode(json_decode($r[$i]['parameter']), ': ');
index 7775fdb..61b523b 100644 (file)
@@ -198,14 +198,14 @@ function community_getitems($start, $itemspage, $content)
                        AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
                        ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
                );
-               return DBA::inArray($r);
+               return DBA::toArray($r);
        } elseif ($content == 'global') {
                $r = DBA::p("SELECT `uri` FROM `thread`
                                INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
                                INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
                                WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked`
                                ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage));
-               return DBA::inArray($r);
+               return DBA::toArray($r);
        }
 
        // Should never happen
index 7991015..50eb025 100644 (file)
@@ -845,7 +845,7 @@ function networkThreadedView(App $a, $update, $parent)
                        local_user(), TERM_OBJ_POST, TERM_HASHTAG,
                        $top_limit, $bottom_limit);
 
-               $data = DBA::inArray($items);
+               $data = DBA::toArray($items);
 
                if (count($data) > 0) {
                        $tag_top_limit = current($data)['order_date'];
index 64b6ca7..21757d4 100644 (file)
@@ -27,7 +27,7 @@ class ContactSelector
                $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
 
                $s = DBA::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $_SESSION['uid']]);
-               $r = DBA::inArray($s);
+               $r = DBA::toArray($s);
 
                if (DBM::is_result($r)) {
                        foreach ($r as $rr) {
index 21c0b41..e0fbff7 100644 (file)
@@ -106,7 +106,7 @@ class ACL extends BaseObject
                        ORDER BY `name` ASC ", intval(local_user())
                );
 
-               $contacts = DBA::inArray($stmt);
+               $contacts = DBA::toArray($stmt);
 
                $arr = ['contact' => $contacts, 'entry' => $o];
 
@@ -171,7 +171,7 @@ class ACL extends BaseObject
                        ORDER BY `name` ASC ", intval(local_user())
                );
 
-               $contacts = DBA::inArray($stmt);
+               $contacts = DBA::toArray($stmt);
 
                $arr = ['contact' => $contacts, 'entry' => $o];
 
index a663cff..68ea884 100644 (file)
@@ -81,7 +81,7 @@ class Addon
                if (strlen($addons)) {
                        $r = DBA::select('addon', [], ['installed' => 1]);
                        if (DBM::is_result($r)) {
-                               $installed = DBA::inArray($r);
+                               $installed = DBA::toArray($r);
                        } else {
                                $installed = [];
                        }
index 2d4a8cb..a8f35d4 100644 (file)
@@ -874,7 +874,7 @@ class Worker
                $r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
                if (DBM::is_result($r)) {
                        self::$db_duration += (microtime(true) - $stamp);
-                       return DBA::inArray($r);
+                       return DBA::toArray($r);
                }
                DBA::close($r);
 
@@ -892,7 +892,7 @@ class Worker
 
                if ($found) {
                        $r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
-                       return DBA::inArray($r);
+                       return DBA::toArray($r);
                }
                return false;
        }
index 64ee3a0..40699fe 100644 (file)
@@ -185,7 +185,7 @@ class DBA
         */
        public static function databaseName() {
                $ret = self::p("SELECT DATABASE() AS `db`");
-               $data = self::inArray($ret);
+               $data = self::toArray($ret);
                return $data[0]['db'];
        }
 
@@ -266,7 +266,7 @@ class DBA
                        case 'pdo':
                                $r = self::p("SELECT 1");
                                if (DBM::is_result($r)) {
-                                       $row = self::inArray($r);
+                                       $row = self::toArray($r);
                                        $connected = ($row[0]['1'] == '1');
                                }
                                break;
@@ -1462,7 +1462,7 @@ class DBA
         * @param object $stmt statement object
         * @return array Data array
         */
-       public static function inArray($stmt, $do_close = true) {
+       public static function toArray($stmt, $do_close = true) {
                if (is_bool($stmt)) {
                        return $stmt;
                }
index 14382d4..c6e270b 100644 (file)
@@ -55,7 +55,7 @@ class Contact extends BaseObject
                                local_user()
                        );
                        if (DBM::is_result($stmt)) {
-                               $return = DBA::inArray($stmt);
+                               $return = DBA::toArray($stmt);
                        }
                }
 
@@ -401,14 +401,14 @@ class Contact extends BaseObject
                $s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
                        `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
                FROM `contact` WHERE `nurl` = ? AND `uid` = ?", normalise_link($url), $uid);
-               $r = DBA::inArray($s);
+               $r = DBA::toArray($s);
 
                // Fetch contact data from the contact table for the given user, checking with the alias
                if (!DBM::is_result($r)) {
                        $s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
                                `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
                        FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ?", normalise_link($url), $url, $ssl_url, $uid);
-                       $r = DBA::inArray($s);
+                       $r = DBA::toArray($s);
                }
 
                // Fetch the data from the contact table with "uid=0" (which is filled automatically)
@@ -416,7 +416,7 @@ class Contact extends BaseObject
                        $s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
                        `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
                        FROM `contact` WHERE `nurl` = ? AND `uid` = 0", normalise_link($url));
-                       $r = DBA::inArray($s);
+                       $r = DBA::toArray($s);
                }
 
                // Fetch the data from the contact table with "uid=0" (which is filled automatically) - checked with the alias
@@ -424,7 +424,7 @@ class Contact extends BaseObject
                        $s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
                        `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
                        FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = 0", normalise_link($url), $url, $ssl_url);
-                       $r = DBA::inArray($s);
+                       $r = DBA::toArray($s);
                }
 
                // Fetch the data from the gcontact table
@@ -432,7 +432,7 @@ class Contact extends BaseObject
                        $s = DBA::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
                        `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, 0 AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
                        FROM `gcontact` WHERE `nurl` = ?", normalise_link($url));
-                       $r = DBA::inArray($s);
+                       $r = DBA::toArray($s);
                }
 
                if (DBM::is_result($r)) {
@@ -866,7 +866,7 @@ class Contact extends BaseObject
                        );
 
                        $s = DBA::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
-                       $contacts = DBA::inArray($s);
+                       $contacts = DBA::toArray($s);
                        if (!DBM::is_result($contacts)) {
                                return 0;
                        }
index be3c06e..c7dc57a 100644 (file)
@@ -739,7 +739,7 @@ class Event extends BaseObject
 
                $events = DBA::select('event', $fields, $conditions);
                if (DBM::is_result($events)) {
-                       $return = DBA::inArray($events);
+                       $return = DBA::toArray($events);
                }
 
                return $return;
index b41866c..f789e98 100644 (file)
@@ -114,7 +114,7 @@ class Group extends BaseObject
                        local_user()
                );
 
-               return DBA::inArray($stmt);
+               return DBA::toArray($stmt);
        }
 
        /**
index 82507b9..4bd3d59 100644 (file)
@@ -557,7 +557,7 @@ class Profile
                                DateTimeFormat::utcNow()
                        );
                        if (DBM::is_result($s)) {
-                               $r = DBA::inArray($s);
+                               $r = DBA::toArray($s);
                                Cache::set($cachekey, $r, CACHE_HOUR);
                        }
                }
index 6422afc..84d3b79 100644 (file)
@@ -43,7 +43,7 @@ class FKOAuthDataStore extends OAuthDataStore
                logger(__function__ . ":" . $consumer_key);
 
                $s = DBA::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]);
-               $r = DBA::inArray($s);
+               $r = DBA::toArray($s);
 
                if (DBM::is_result($r)) {
                        return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
@@ -63,7 +63,7 @@ class FKOAuthDataStore extends OAuthDataStore
                logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
 
                $s = DBA::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]);
-               $r = DBA::inArray($s);
+               $r = DBA::toArray($s);
 
                if (DBM::is_result($r)) {
                        $ot = new OAuthToken($r[0]['id'], $r[0]['secret']);
index efdccb6..7ba8b60 100644 (file)
@@ -408,7 +408,7 @@ class Notifier
                                $condition['network'] = $networks;
                        }
                        $contacts = DBA::select('contact', ['id', 'url', 'network'], $condition);
-                       $r = DBA::inArray($contacts);
+                       $r = DBA::toArray($contacts);
                }
 
                // delivery loop
@@ -458,7 +458,7 @@ class Notifier
 
                        $condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
                                'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
-                       $r2 = DBA::inArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
+                       $r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
 
                        $r = array_merge($r2, $r1);
 
index 25c963f..b37a32f 100644 (file)
@@ -36,7 +36,7 @@ class Queue
                        // Handling the pubsubhubbub requests
                        PushSubscriber::requeue();
 
-                       $r = DBA::inArray(DBA::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
+                       $r = DBA::toArray(DBA::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
 
                        Addon::callHooks('queue_predeliver', $r);