mirror of
https://github.com/friendica/friendica
synced 2025-04-25 17:50:11 +00:00
Replace dba::select(limit => 1) by dba::selectOne
- Convert array declarations to new style
This commit is contained in:
parent
a2d3cee006
commit
da60893590
51 changed files with 206 additions and 219 deletions
|
@ -103,7 +103,7 @@ class Contact extends BaseObject
|
|||
return true;
|
||||
}
|
||||
|
||||
$user = dba::select('user', ['uid', 'username', 'nickname'], ['uid' => $uid], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ class Contact extends BaseObject
|
|||
public static function remove($id)
|
||||
{
|
||||
// We want just to make sure that we don't delete our "self" contact
|
||||
$r = dba::select('contact', array('uid'), array('id' => $id, 'self' => false), array('limit' => 1));
|
||||
$r = dba::selectOne('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
|
||||
if (!DBM::is_result($r) || !intval($r['uid'])) {
|
||||
return;
|
||||
|
@ -490,7 +490,7 @@ class Contact extends BaseObject
|
|||
return $menu;
|
||||
}
|
||||
|
||||
$r = dba::select('contact', array(), array('nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid), array('limit' => 1));
|
||||
$r = dba::selectOne('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
|
||||
if ($r) {
|
||||
return self::photoMenu($r, $uid);
|
||||
} else {
|
||||
|
@ -653,18 +653,18 @@ class Contact extends BaseObject
|
|||
|
||||
/// @todo Verify if we can't use Contact::getDetailsByUrl instead of the following
|
||||
// We first try the nurl (http://server.tld/nick), most common case
|
||||
$contact = dba::select('contact', array('id', 'avatar-date'), array('nurl' => normalise_link($url), 'uid' => $uid), array('limit' => 1));
|
||||
$contact = dba::selectOne('contact', ['id', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
|
||||
|
||||
// Then the addr (nick@server.tld)
|
||||
if (!DBM::is_result($contact)) {
|
||||
$contact = dba::select('contact', array('id', 'avatar-date'), array('addr' => $url, 'uid' => $uid), array('limit' => 1));
|
||||
$contact = dba::selectOne('contact', ['id', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
// Then the alias (which could be anything)
|
||||
if (!DBM::is_result($contact)) {
|
||||
// The link could be provided as http although we stored it as https
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
$r = dba::select('contact', array('id', 'avatar', 'avatar-date'), array('`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid), array('limit' => 1));
|
||||
$r = dba::selectOne('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
|
||||
$contact = dba::fetch($r);
|
||||
dba::close($r);
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
// Get data from the gcontact table
|
||||
$gcontacts = dba::select('gcontact', array('name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'), array('nurl' => normalise_link($url)), array('limit' => 1));
|
||||
$gcontacts = dba::selectOne('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
|
||||
if (!DBM::is_result($gcontacts)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ class Contact extends BaseObject
|
|||
$contact_id = $contacts[0]["id"];
|
||||
|
||||
// Update the newly created contact from data in the gcontact table
|
||||
$gcontact = dba::select('gcontact', array('location', 'about', 'keywords', 'gender'), array('nurl' => normalise_link($data["url"])), array('limit' => 1));
|
||||
$gcontact = dba::selectOne('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
|
||||
if (DBM::is_result($gcontact)) {
|
||||
// Only use the information when the probing hadn't fetched these values
|
||||
if ($data['keywords'] != '') {
|
||||
|
@ -758,8 +758,8 @@ class Contact extends BaseObject
|
|||
|
||||
self::updateAvatar($data["photo"], $uid, $contact_id);
|
||||
|
||||
$fields = array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey');
|
||||
$contact = dba::select('contact', $fields, array('id' => $contact_id), array('limit' => 1));
|
||||
$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
|
||||
$contact = dba::selectOne('contact', $fields, ['id' => $contact_id]);
|
||||
|
||||
// This condition should always be true
|
||||
if (!DBM::is_result($contact)) {
|
||||
|
@ -817,7 +817,7 @@ class Contact extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$blocked = dba::select('contact', array('blocked'), array('id' => $cid), array('limit' => 1));
|
||||
$blocked = dba::selectOne('contact', ['blocked'], ['id' => $cid]);
|
||||
if (!DBM::is_result($blocked)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -837,7 +837,7 @@ class Contact extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$hidden = dba::select('contact', array('hidden'), array('id' => $cid), array('limit' => 1));
|
||||
$hidden = dba::selectOne('contact', ['hidden'], ['id' => $cid]);
|
||||
if (!DBM::is_result($hidden)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ class Contact extends BaseObject
|
|||
public static function updateAvatar($avatar, $uid, $cid, $force = false)
|
||||
{
|
||||
// Limit = 1 returns the row so no need for dba:inArray()
|
||||
$r = dba::select('contact', array('avatar', 'photo', 'thumb', 'micro', 'nurl'), array('id' => $cid), array('limit' => 1));
|
||||
$r = dba::selectOne('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -999,7 +999,7 @@ class Contact extends BaseObject
|
|||
|
||||
// Update the public contact (contact id = 0)
|
||||
if ($uid != 0) {
|
||||
$pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
|
||||
$pcontact = dba::selectOne('contact', ['id'], ['nurl' => $r[0]['nurl']]);
|
||||
if (DBM::is_result($pcontact)) {
|
||||
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
|
||||
}
|
||||
|
@ -1023,7 +1023,7 @@ class Contact extends BaseObject
|
|||
This will reliably kill your communication with Friendica contacts.
|
||||
*/
|
||||
|
||||
$r = dba::select('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id], ['limit' => 1]);
|
||||
$r = dba::selectOne('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1246,7 +1246,7 @@ class Contact extends BaseObject
|
|||
);
|
||||
}
|
||||
|
||||
$r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
|
||||
$r = dba::selectOne('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
$result['message'] .= t('Unable to retrieve contact information.') . EOL;
|
||||
|
|
|
@ -888,7 +888,7 @@ class GContact
|
|||
'network', 'bd', 'gender',
|
||||
'keywords', 'alias', 'contact-type',
|
||||
'url', 'location', 'about');
|
||||
$old_contact = dba::select('contact', $fields, array('id' => $r[0]["id"]), array('limit' => 1));
|
||||
$old_contact = dba::selectOne('contact', $fields, ['id' => $r[0]["id"]]);
|
||||
|
||||
// Update it with the current values
|
||||
$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
|
||||
|
|
|
@ -39,7 +39,7 @@ class Group extends BaseObject
|
|||
// all the old members are gone, but the group remains so we don't break any security
|
||||
// access lists. What we're doing here is reviving the dead group, but old content which
|
||||
// was restricted to this group may now be seen by the new group members.
|
||||
$group = dba::select('group', ['deleted'], ['id' => $gid], ['limit' => 1]);
|
||||
$group = dba::selectOne('group', ['deleted'], ['id' => $gid]);
|
||||
if (DBM::is_result($group) && $group['deleted']) {
|
||||
dba::update('group', ['deleted' => 0], ['gid' => $gid]);
|
||||
notice(t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
|
||||
|
@ -120,7 +120,7 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = dba::select('group', ['id'], ['uid' => $uid, 'name' => $name], ['limit' => 1]);
|
||||
$group = dba::selectOne('group', ['id'], ['uid' => $uid, 'name' => $name]);
|
||||
if (DBM::is_result($group)) {
|
||||
return $group['id'];
|
||||
}
|
||||
|
@ -139,13 +139,13 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = dba::select('group', ['uid'], ['gid' => $gid], ['limit' => 1]);
|
||||
$group = dba::selectOne('group', ['uid'], ['gid' => $gid]);
|
||||
if (!DBM::is_result($group)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove group from default posting lists
|
||||
$user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
|
||||
if (DBM::is_result($user)) {
|
||||
$change = false;
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ class Photo
|
|||
*/
|
||||
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
|
||||
{
|
||||
$r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
|
||||
$r = dba::selectOne('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
|
||||
if (DBM::is_result($r)) {
|
||||
$guid = $r['guid'];
|
||||
} else {
|
||||
$guid = get_guid();
|
||||
}
|
||||
|
||||
$x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
|
||||
$x = dba::selectOne('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
|
||||
|
||||
$fields = array(
|
||||
'uid' => $uid,
|
||||
|
@ -88,8 +88,8 @@ class Photo
|
|||
*/
|
||||
public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
|
||||
{
|
||||
$r = dba::select(
|
||||
'photo', array('resource-id'), array('uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'), array('limit' => 1)
|
||||
$r = dba::selectOne(
|
||||
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
|
||||
);
|
||||
|
||||
if (DBM::is_result($r) && strlen($r['resource-id'])) {
|
||||
|
|
|
@ -84,7 +84,7 @@ class User
|
|||
return $default_group;
|
||||
}
|
||||
|
||||
$user = dba::select('user', ['def_gid'], ['uid' => $uid], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', ['def_gid'], ['uid' => $uid]);
|
||||
|
||||
if (DBM::is_result($user)) {
|
||||
$default_group = $user["def_gid"];
|
||||
|
@ -112,16 +112,14 @@ class User
|
|||
if (is_object($user_info)) {
|
||||
$user = (array) $user_info;
|
||||
} elseif (is_int($user_info)) {
|
||||
$user = dba::select('user',
|
||||
['uid', 'password'],
|
||||
$user = dba::selectOne('user', ['uid', 'password'],
|
||||
[
|
||||
'uid' => $user_info,
|
||||
'blocked' => 0,
|
||||
'account_expired' => 0,
|
||||
'account_removed' => 0,
|
||||
'verified' => 1
|
||||
],
|
||||
['limit' => 1]
|
||||
]
|
||||
);
|
||||
} elseif (is_string($user_info)) {
|
||||
$user = dba::fetch_first('SELECT `uid`, `password`
|
||||
|
@ -330,7 +328,7 @@ class User
|
|||
|
||||
if ($insert_result) {
|
||||
$uid = dba::lastInsertId();
|
||||
$user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', [], ['uid' => $uid]);
|
||||
} else {
|
||||
throw new Exception(t('An error occurred during registration. Please try again.'));
|
||||
}
|
||||
|
@ -532,7 +530,7 @@ class User
|
|||
|
||||
logger('Removing user: ' . $uid);
|
||||
|
||||
$user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', [], ['uid' => $uid]);
|
||||
|
||||
call_hooks('remove_user', $user);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue