From 4db98eb43d90a56b1e983628910641c9cc567b8a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan <mrpetovan@gmail.com> Date: Fri, 20 Jul 2018 22:03:40 -0400 Subject: [PATCH] Rename DBA::inArray to DBA::toArray --- include/dba.php | 2 +- include/security.php | 8 ++++---- mod/admin.php | 4 ++-- mod/community.php | 4 ++-- mod/network.php | 2 +- src/Content/ContactSelector.php | 2 +- src/Core/ACL.php | 4 ++-- src/Core/Addon.php | 2 +- src/Core/Worker.php | 4 ++-- src/Database/DBA.php | 6 +++--- src/Model/Contact.php | 14 +++++++------- src/Model/Event.php | 2 +- src/Model/Group.php | 2 +- src/Model/Profile.php | 2 +- src/Network/FKOAuthDataStore.php | 4 ++-- src/Worker/Notifier.php | 4 ++-- src/Worker/Queue.php | 2 +- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/dba.php b/include/dba.php index 32d3b1dde..bccd9792b 100644 --- a/include/dba.php +++ b/include/dba.php @@ -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; diff --git a/include/security.php b/include/security.php index 987f3b08e..53e554c3d 100644 --- a/include/security.php +++ b/include/security.php @@ -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) { diff --git a/mod/admin.php b/mod/admin.php index a6a09112e..7c465fe17 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -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']), ': '); diff --git a/mod/community.php b/mod/community.php index 7775fdba4..61b523ba4 100644 --- a/mod/community.php +++ b/mod/community.php @@ -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 diff --git a/mod/network.php b/mod/network.php index 79910152b..50eb025c2 100644 --- a/mod/network.php +++ b/mod/network.php @@ -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']; diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index 64b6ca7c6..21757d429 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -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) { diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 21c0b41bd..e0fbff7eb 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -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]; diff --git a/src/Core/Addon.php b/src/Core/Addon.php index a663cff50..68ea88483 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -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 = []; } diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 2d4a8cb94..a8f35d4f3 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -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; } diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 64ee3a00d..40699feac 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -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; } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 14382d418..c6e270b6e 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -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; } diff --git a/src/Model/Event.php b/src/Model/Event.php index be3c06eeb..c7dc57a93 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -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; diff --git a/src/Model/Group.php b/src/Model/Group.php index b41866c6e..f789e98ad 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -114,7 +114,7 @@ class Group extends BaseObject local_user() ); - return DBA::inArray($stmt); + return DBA::toArray($stmt); } /** diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 82507b9c0..4bd3d59cf 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -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); } } diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index 6422afcf9..84d3b790b 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -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']); diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index efdccb6b1..7ba8b60b3 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -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); diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index 25c963fab..b37a32f9e 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -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);