mirror of
https://github.com/friendica/friendica
synced 2025-04-28 21:44:22 +02: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
|
@ -2015,7 +2015,7 @@ class Diaspora
|
|||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($parent_item["id"] != $parent_item["parent"]) {
|
||||
$toplevel = dba::select('item', array('origin'), array('id' => $parent_item["parent"]), array('limit' => 1));
|
||||
$toplevel = dba::selectOne('item', ['origin'], ['id' => $parent_item["parent"]]);
|
||||
$origin = $toplevel["origin"];
|
||||
} else {
|
||||
$origin = $parent_item["origin"];
|
||||
|
@ -2317,7 +2317,7 @@ class Diaspora
|
|||
|
||||
$arr["last-child"] = 1;
|
||||
|
||||
$user = dba::select('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]], ['limit' => 1]);
|
||||
$user = dba::selectOne('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]]);
|
||||
|
||||
$arr["allow_cid"] = $user["allow_cid"];
|
||||
$arr["allow_gid"] = $user["allow_gid"];
|
||||
|
@ -2741,7 +2741,7 @@ class Diaspora
|
|||
|
||||
while ($item = dba::fetch($r)) {
|
||||
// Fetch the parent item
|
||||
$parent = dba::select('item', array('author-link', 'origin'), array('id' => $item["parent"]), array('limit' => 1));
|
||||
$parent = dba::selectOne('item', ['author-link', 'origin'], ['id' => $item["parent"]]);
|
||||
|
||||
// Only delete it if the parent author really fits
|
||||
if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
|
||||
|
@ -3255,7 +3255,7 @@ class Diaspora
|
|||
// If the item belongs to a user, we take this user id.
|
||||
if ($item['uid'] == 0) {
|
||||
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
|
||||
$first_user = dba::select('user', ['uid'], $condition, ['limit' => 1]);
|
||||
$first_user = dba::selectOne('user', ['uid'], $condition);
|
||||
$owner = User::getOwnerDataById($first_user['uid']);
|
||||
} else {
|
||||
$owner = User::getOwnerDataById($item['uid']);
|
||||
|
|
|
@ -254,7 +254,7 @@ class Feed {
|
|||
if (!$simulate) {
|
||||
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
||||
$previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
|
||||
$previous = dba::selectOne('item', ['id'], $condition);
|
||||
if (DBM::is_result($previous)) {
|
||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
||||
continue;
|
||||
|
|
|
@ -70,9 +70,9 @@ class OStatus
|
|||
$found = false;
|
||||
|
||||
if ($aliaslink != '') {
|
||||
$condition = array("`uid` = ? AND `alias` = ? AND `network` != ?",
|
||||
$importer["uid"], $aliaslink, NETWORK_STATUSNET);
|
||||
$r = dba::select('contact', array(), $condition, array('limit' => 1));
|
||||
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
|
||||
$importer["uid"], $aliaslink, NETWORK_STATUSNET];
|
||||
$r = dba::selectOne('contact', [], $condition);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$found = true;
|
||||
|
@ -89,9 +89,9 @@ class OStatus
|
|||
$aliaslink = $author["author-link"];
|
||||
}
|
||||
|
||||
$condition = array("`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
|
||||
normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET);
|
||||
$r = dba::select('contact', array(), $condition, array('limit' => 1));
|
||||
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
|
||||
normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
|
||||
$r = dba::selectOne('contact', [], $condition);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$found = true;
|
||||
|
@ -104,9 +104,9 @@ class OStatus
|
|||
}
|
||||
|
||||
if (!$found && ($addr != "")) {
|
||||
$condition = array("`uid` = ? AND `addr` = ? AND `network` != ?",
|
||||
$importer["uid"], $addr, NETWORK_STATUSNET);
|
||||
$r = dba::select('contact', array(), $condition, array('limit' => 1));
|
||||
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
|
||||
$importer["uid"], $addr, NETWORK_STATUSNET];
|
||||
$r = dba::selectOne('contact', [], $condition);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$found = true;
|
||||
|
@ -207,8 +207,8 @@ class OStatus
|
|||
$cid = Contact::getIdForURL($aliaslink, 0);
|
||||
|
||||
if ($cid) {
|
||||
$fields = array('url', 'nurl', 'name', 'nick', 'alias', 'about', 'location');
|
||||
$old_contact = dba::select('contact', $fields, array('id' => $cid), array('limit' => 1));
|
||||
$fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
|
||||
$old_contact = dba::selectOne('contact', $fields, ['id' => $cid]);
|
||||
|
||||
// Update it with the current values
|
||||
$fields = array('url' => $author["author-link"], 'name' => $contact["name"],
|
||||
|
@ -541,8 +541,8 @@ class OStatus
|
|||
*/
|
||||
private static function deleteNotice($item)
|
||||
{
|
||||
$condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
|
||||
$deleted = dba::select('item', array('id', 'parent-uri'), $condition, array('limit' => 1));
|
||||
$condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
|
||||
$deleted = dba::selectOne('item', ['id', 'parent-uri'], $condition);
|
||||
if (!DBM::is_result($deleted)) {
|
||||
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
|
||||
return;
|
||||
|
@ -895,8 +895,8 @@ class OStatus
|
|||
*/
|
||||
private static function fetchRelated($related, $related_uri, $importer)
|
||||
{
|
||||
$condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
|
||||
$conversation = dba::select('conversation', array('source', 'protocol'), $condition, array('limit' => 1));
|
||||
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
|
||||
$conversation = dba::selectOne('conversation', ['source', 'protocol'], $condition);
|
||||
if (DBM::is_result($conversation)) {
|
||||
$stored = true;
|
||||
$xml = $conversation['source'];
|
||||
|
@ -975,8 +975,8 @@ class OStatus
|
|||
|
||||
// Finally we take the data that we fetched from "ostatus:conversation"
|
||||
if ($xml == '') {
|
||||
$condition = array('item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV);
|
||||
$conversation = dba::select('conversation', array('source'), $condition, array('limit' => 1));
|
||||
$condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
|
||||
$conversation = dba::selectOne('conversation', ['source'], $condition);
|
||||
if (DBM::is_result($conversation)) {
|
||||
$stored = true;
|
||||
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
|
||||
|
|
|
@ -66,7 +66,7 @@ class PortableContact
|
|||
|
||||
if ($cid) {
|
||||
if (!$url || !$uid) {
|
||||
$r = dba::select('contact', ['poco', 'uid'], ['id' => $cid], ['limit' => 1]);
|
||||
$r = dba::selectOne('contact', ['poco', 'uid'], ['id' => $cid]);
|
||||
if (DBM::is_result($r)) {
|
||||
$url = $r['poco'];
|
||||
$uid = $r['uid'];
|
||||
|
@ -813,7 +813,7 @@ class PortableContact
|
|||
return false;
|
||||
}
|
||||
|
||||
$servers = dba::select('gserver', [], ['nurl' => normalise_link($server_url)], ['limit' => 1]);
|
||||
$servers = dba::selectOne('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($servers)) {
|
||||
if ($servers["created"] <= NULL_DATE) {
|
||||
$fields = ['created' => datetime_convert()];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue