mirror of
https://github.com/friendica/friendica
synced 2025-05-09 16:24:12 +02:00
Rename DBM method calls to DBA method calls
This commit is contained in:
parent
8ddb94ef06
commit
0ec44f3e8a
153 changed files with 813 additions and 918 deletions
|
@ -19,7 +19,6 @@ use Friendica\Core\PConfig;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
|
@ -71,7 +70,7 @@ class Diaspora
|
|||
if (Config::get("system", "relay_directly", false)) {
|
||||
// We distribute our stuff based on the parent to ensure that the thread will be complete
|
||||
$parent = Item::selectFirst(['parent'], ['id' => $item_id]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
if (!DBA::is_result($parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,7 +147,7 @@ class Diaspora
|
|||
'contact-type' => ACCOUNT_TYPE_RELAY];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
|
||||
if (DBM::is_result($contact)) {
|
||||
if (DBA::is_result($contact)) {
|
||||
if ($contact['archive'] || $contact['blocked']) {
|
||||
return false;
|
||||
}
|
||||
|
@ -157,7 +156,7 @@ class Diaspora
|
|||
self::setRelayContact($server_url);
|
||||
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
if (DBM::is_result($contact)) {
|
||||
if (DBA::is_result($contact)) {
|
||||
return $contact;
|
||||
}
|
||||
}
|
||||
|
@ -900,7 +899,7 @@ class Diaspora
|
|||
$update = false;
|
||||
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
|
||||
if (DBM::is_result($person)) {
|
||||
if (DBA::is_result($person)) {
|
||||
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
|
||||
|
||||
// update record occasionally so it doesn't get stale
|
||||
|
@ -914,7 +913,7 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
if (!DBM::is_result($person) || $update) {
|
||||
if (!DBA::is_result($person) || $update) {
|
||||
logger("create or refresh", LOGGER_DEBUG);
|
||||
$r = Probe::uri($handle, NETWORK_DIASPORA);
|
||||
|
||||
|
@ -925,7 +924,7 @@ class Diaspora
|
|||
|
||||
// Fetch the updated or added contact
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
|
||||
if (!DBM::is_result($person)) {
|
||||
if (!DBA::is_result($person)) {
|
||||
$person = $r;
|
||||
}
|
||||
}
|
||||
|
@ -974,7 +973,7 @@ class Diaspora
|
|||
intval($pcontact_id)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
return strtolower($r[0]["addr"]);
|
||||
}
|
||||
}
|
||||
|
@ -984,7 +983,7 @@ class Diaspora
|
|||
intval($contact_id)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact = $r[0];
|
||||
|
||||
logger("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], LOGGER_DEBUG);
|
||||
|
@ -1021,7 +1020,7 @@ class Diaspora
|
|||
dbesc($fcontact_guid)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
return $r[0]['url'];
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1052,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $cid]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
if (!DBA::is_result($contact)) {
|
||||
// This here shouldn't happen at all
|
||||
logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
|
||||
return false;
|
||||
|
@ -1154,7 +1153,7 @@ class Diaspora
|
|||
private static function messageExists($uid, $guid)
|
||||
{
|
||||
$item = Item::selectFirst(['id'], ['uid' => $uid, 'guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
logger("message ".$guid." already exists for user ".$uid);
|
||||
return $item["id"];
|
||||
}
|
||||
|
@ -1374,7 +1373,7 @@ class Diaspora
|
|||
$condition = ['uid' => $uid, 'guid' => $guid];
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
$result = self::storeByGuid($guid, $contact["url"], $uid);
|
||||
|
||||
if (!$result) {
|
||||
|
@ -1389,7 +1388,7 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
logger("parent item not found: parent: ".$guid." - user: ".$uid);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1413,7 +1412,7 @@ class Diaspora
|
|||
{
|
||||
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
|
||||
if (DBM::is_result($contact)) {
|
||||
if (DBA::is_result($contact)) {
|
||||
$cid = $contact["id"];
|
||||
$network = $contact["network"];
|
||||
} else {
|
||||
|
@ -1569,7 +1568,7 @@ class Diaspora
|
|||
private static function getUriFromGuid($author, $guid, $onlyfound = false)
|
||||
{
|
||||
$item = Item::selectFirst(['uri'], ['guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
return $item["uri"];
|
||||
} elseif (!$onlyfound) {
|
||||
$contact = Contact::getDetailsByAddr($author, 0);
|
||||
|
@ -1599,7 +1598,7 @@ class Diaspora
|
|||
private static function getGuidFromUri($uri, $uid)
|
||||
{
|
||||
$item = Item::selectFirst(['guid'], ['uri' => $uri, 'uid' => $uid]);
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
return $item["guid"];
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1616,10 +1615,10 @@ class Diaspora
|
|||
private static function importerForGuid($guid)
|
||||
{
|
||||
$item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
|
||||
$contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
|
||||
if (DBM::is_result($contact)) {
|
||||
if (DBA::is_result($contact)) {
|
||||
return $contact;
|
||||
}
|
||||
}
|
||||
|
@ -1791,7 +1790,7 @@ class Diaspora
|
|||
dbesc($msg_guid),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
logger("duplicate message already delivered.", LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -2078,7 +2077,7 @@ class Diaspora
|
|||
dbesc($guid),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
logger("duplicate message already delivered.", LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -2134,7 +2133,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
logger('Item not found, no origin or private: '.$parent_guid);
|
||||
return false;
|
||||
}
|
||||
|
@ -2518,7 +2517,7 @@ class Diaspora
|
|||
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
logger("reshared message ".$guid." already exists on system.");
|
||||
|
||||
// Maybe it is already a reshared item?
|
||||
|
@ -2540,7 +2539,7 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
if (empty($orig_author)) {
|
||||
logger('Empty author for guid ' . $guid . '. Quitting.');
|
||||
return false;
|
||||
|
@ -2562,7 +2561,7 @@ class Diaspora
|
|||
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
||||
if (self::isReshare($item["body"], false)) {
|
||||
$item["body"] = Markdown::toBBCode(BBCode::toMarkdown($item["body"]));
|
||||
|
@ -2704,7 +2703,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$r = Item::select($fields, $condition);
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");
|
||||
return false;
|
||||
}
|
||||
|
@ -3357,7 +3356,7 @@ class Diaspora
|
|||
if (($guid != "") && $complete) {
|
||||
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
|
||||
$item = Item::selectFirst(['contact-id'], $condition);
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
$ret= [];
|
||||
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
|
||||
$ret["root_guid"] = $guid;
|
||||
|
@ -3410,7 +3409,7 @@ class Diaspora
|
|||
private static function buildEvent($event_id)
|
||||
{
|
||||
$r = q("SELECT `guid`, `uid`, `start`, `finish`, `nofinish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id));
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -3419,14 +3418,14 @@ class Diaspora
|
|||
$eventdata = [];
|
||||
|
||||
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d", intval($event['uid']));
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$user = $r[0];
|
||||
|
||||
$r = q("SELECT `addr`, `nick` FROM `contact` WHERE `uid` = %d AND `self`", intval($event['uid']));
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -3624,7 +3623,7 @@ class Diaspora
|
|||
private static function constructLike(array $item, array $owner)
|
||||
{
|
||||
$parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
if (!DBA::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3655,7 +3654,7 @@ class Diaspora
|
|||
private static function constructAttend(array $item, array $owner)
|
||||
{
|
||||
$parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
if (!DBA::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3699,7 +3698,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$parent = Item::selectFirst(['guid'], ['id' => $item["parent"], 'parent' => $item["parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
if (!DBA::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3925,7 +3924,7 @@ class Diaspora
|
|||
intval($item["uid"])
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
logger("conversation not found.");
|
||||
return;
|
||||
}
|
||||
|
@ -4165,14 +4164,14 @@ class Diaspora
|
|||
}
|
||||
|
||||
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact["uprvkey"] = $r[0]['prvkey'];
|
||||
|
||||
$item = Item::selectFirst([], ['id' => $post_id]);
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue