Browse Source

Rename DBA::inArray to DBA::toArray

pull/5431/head
Hypolite Petovan 3 years ago
parent
commit
4db98eb43d
  1. 2
      include/dba.php
  2. 8
      include/security.php
  3. 4
      mod/admin.php
  4. 4
      mod/community.php
  5. 2
      mod/network.php
  6. 2
      src/Content/ContactSelector.php
  7. 4
      src/Core/ACL.php
  8. 2
      src/Core/Addon.php
  9. 4
      src/Core/Worker.php
  10. 6
      src/Database/DBA.php
  11. 14
      src/Model/Contact.php
  12. 2
      src/Model/Event.php
  13. 2
      src/Model/Group.php
  14. 2
      src/Model/Profile.php
  15. 4
      src/Network/FKOAuthDataStore.php
  16. 4
      src/Worker/Notifier.php
  17. 2
      src/Worker/Queue.php

2
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;

8
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) {

4
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']), ': ');

4
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

2
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'];

2
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) {

4
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];

2
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 = [];
}

4
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;
}

6
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;
}

14
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;
}

2
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;

2
src/Model/Group.php

@ -114,7 +114,7 @@ class Group extends BaseObject
local_user()
);
return DBA::inArray($stmt);
return DBA::toArray($stmt);
}
/**

2
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);
}
}

4
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']);

4
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);

2
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);

Loading…
Cancel
Save