Rename Friendica\Database\dba to Friendica\Database\DBA

This commit is contained in:
Hypolite Petovan 2018-07-20 08:19:26 -04:00
parent b6a1df0598
commit af6dbc654f
127 changed files with 1169 additions and 1169 deletions

View file

@ -18,7 +18,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Event;
@ -952,7 +952,7 @@ class DFRN
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
$conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
if (DBM::is_result($conversation)) {
if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
@ -1401,7 +1401,7 @@ class DFRN
if (empty($contact['addr'])) {
logger('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
if (Contact::updateFromProbe($contact['id'])) {
$new_contact = dba::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
$new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
$contact['addr'] = $new_contact['addr'];
}
@ -1543,7 +1543,7 @@ class DFRN
'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
$condition = ["`uid` = ? AND `nurl` = ? AND `network` != ?",
$importer["importer_uid"], normalise_link($author["link"]), NETWORK_STATUSNET];
$contact_old = dba::selectFirst('contact', $fields, $condition);
$contact_old = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact_old)) {
$author["contact-id"] = $contact_old["id"];
@ -1855,7 +1855,7 @@ class DFRN
$msg["seen"] = 0;
$msg["replied"] = 0;
dba::insert('mail', $msg);
DBA::insert('mail', $msg);
// send notifications.
/// @TODO Arange this mess
@ -2074,7 +2074,7 @@ class DFRN
'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
'addr' => $relocate["addr"], 'connect' => $relocate["addr"],
'notify' => $relocate["notify"], 'server_url' => $relocate["server_url"]];
dba::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
// Update the contact table. We try to find every entry.
$fields = ['name' => $relocate["name"], 'avatar' => $relocate["avatar"],
@ -2084,7 +2084,7 @@ class DFRN
'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], normalise_link($old["url"])];
dba::update('contact', $fields, $condition);
DBA::update('contact', $fields, $condition);
Contact::updateAvatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
@ -2228,7 +2228,7 @@ class DFRN
}
if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = dba::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
// send a notification
notification(
@ -2851,16 +2851,16 @@ class DFRN
$accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
if ($accounttype != $importer["contact-type"]) {
dba::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
}
// A forum contact can either have set "forum" or "prv" - but not both
if (($accounttype == ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer["id"]];
dba::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
}
} elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
dba::update('contact', ['forum' => $forum], $condition);
DBA::update('contact', ['forum' => $forum], $condition);
}
@ -2988,7 +2988,7 @@ class DFRN
$sec = random_string();
dba::insert('profile_check', ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]);
DBA::insert('profile_check', ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]);
$url = curPageURL();

View file

@ -18,7 +18,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
@ -76,32 +76,32 @@ class Diaspora
}
// Servers that want to get all content
$servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
while ($server = dba::fetch($servers)) {
$servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
// All tags of the current post
$condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $parent['parent']];
$tags = dba::select('term', ['term'], $condition);
$tags = DBA::select('term', ['term'], $condition);
$taglist = [];
while ($tag = dba::fetch($tags)) {
while ($tag = DBA::fetch($tags)) {
$taglist[] = $tag['term'];
}
// All servers who wants content with this tag
$tagserverlist = [];
if (!empty($taglist)) {
$tagserver = dba::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
while ($server = dba::fetch($tagserver)) {
$tagserver = DBA::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
while ($server = DBA::fetch($tagserver)) {
$tagserverlist[] = $server['gserver-id'];
}
}
// All adresses with the given id
if (!empty($tagserverlist)) {
$servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
while ($server = dba::fetch($servers)) {
$servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
}
@ -146,7 +146,7 @@ class Diaspora
// Fetch the relay contact
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
$contact = dba::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
if ($contact['archive'] || $contact['blocked']) {
@ -156,7 +156,7 @@ class Diaspora
} else {
self::setRelayContact($server_url);
$contact = dba::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
return $contact;
}
@ -186,11 +186,11 @@ class Diaspora
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
if (dba::exists('contact', $condition)) {
if (DBA::exists('contact', $condition)) {
unset($fields['created']);
}
dba::update('contact', $fields, $condition, true);
DBA::update('contact', $fields, $condition, true);
}
/**
@ -207,13 +207,13 @@ class Diaspora
*/
public static function participantsForThread($thread, array $contacts)
{
$r = dba::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
$r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
`fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
WHERE `participation`.`iid` = ?", $thread);
while ($contact = dba::fetch($r)) {
while ($contact = DBA::fetch($r)) {
if (!empty($contact['fnetwork'])) {
$contact['network'] = $contact['fnetwork'];
}
@ -235,7 +235,7 @@ class Diaspora
$contacts[] = $contact;
}
}
dba::close($r);
DBA::close($r);
return $contacts;
}
@ -899,7 +899,7 @@ class Diaspora
{
$update = false;
$person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (DBM::is_result($person)) {
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
@ -924,7 +924,7 @@ class Diaspora
self::updateFContact($r);
// Fetch the updated or added contact
$person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (!DBM::is_result($person)) {
$person = $r;
}
@ -951,7 +951,7 @@ class Diaspora
$condition = ['url' => $arr["url"], 'network' => $arr["network"]];
dba::update('fcontact', $fields, $condition, true);
DBA::update('fcontact', $fields, $condition, true);
}
/**
@ -1425,7 +1425,7 @@ class Diaspora
private static function authorContactByUrl($def_contact, $person, $uid)
{
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
$contact = dba::selectFirst('contact', ['id', 'network'], $condition);
$contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
if (DBM::is_result($contact)) {
$cid = $contact["id"];
$network = $contact["network"];
@ -1532,7 +1532,7 @@ class Diaspora
'notify' => $data['notify'], 'poll' => $data['poll'],
'network' => $data['network']];
dba::update('contact', $fields, ['addr' => $old_handle]);
DBA::update('contact', $fields, ['addr' => $old_handle]);
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
'name' => $data['name'], 'nick' => $data['nick'],
@ -1540,7 +1540,7 @@ class Diaspora
'notify' => $data['notify'], 'photo' => $data['photo'],
'server_url' => $data['baseurl'], 'network' => $data['network']];
dba::update('gcontact', $fields, ['addr' => $old_handle]);
DBA::update('gcontact', $fields, ['addr' => $old_handle]);
logger('Contacts are updated.');
@ -1558,12 +1558,12 @@ class Diaspora
{
$author = notags(unxmlify($data->author));
$contacts = dba::select('contact', ['id'], ['addr' => $author]);
while ($contact = dba::fetch($contacts)) {
$contacts = DBA::select('contact', ['id'], ['addr' => $author]);
while ($contact = DBA::fetch($contacts)) {
Contact::remove($contact["id"]);
}
dba::delete('gcontact', ['addr' => $author]);
DBA::delete('gcontact', ['addr' => $author]);
logger('Removed contacts for ' . $author);
@ -1631,7 +1631,7 @@ class Diaspora
$item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]);
if (DBM::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
$contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
$contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
if (DBM::is_result($contact)) {
return $contact;
}
@ -1797,7 +1797,7 @@ class Diaspora
$person = self::personByHandle($msg_author);
dba::lock('mail');
DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
@ -1828,9 +1828,9 @@ class Diaspora
dbesc($msg_created_at)
);
dba::unlock();
DBA::unlock();
dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
notification(
[
@ -2084,7 +2084,7 @@ class Diaspora
$body = self::replacePeopleGuid($body, $person["url"]);
dba::lock('mail');
DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
@ -2115,9 +2115,9 @@ class Diaspora
dbesc($created_at)
);
dba::unlock();
DBA::unlock();
dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
return true;
}
@ -2162,8 +2162,8 @@ class Diaspora
logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG);
if (!dba::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
}
// Send all existing comments and likes to the requesting server
@ -2180,7 +2180,7 @@ class Diaspora
logger("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG);
Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id);
}
dba::close($comments);
DBA::close($comments);
return true;
}
@ -2291,7 +2291,7 @@ class Diaspora
$fields['bd'] = $birthday;
}
dba::update('contact', $fields, ['id' => $contact['id']]);
DBA::update('contact', $fields, ['id' => $contact['id']]);
$gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
"photo" => $image_url, "name" => $name, "location" => $location,
@ -2320,7 +2320,7 @@ class Diaspora
$a = get_app();
if ($contact["rel"] == CONTACT_IS_SHARING) {
dba::update(
DBA::update(
'contact',
['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
@ -3213,7 +3213,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::selectFirst('user', ['uid'], $condition);
$first_user = DBA::selectFirst('user', ['uid'], $condition);
$owner = User::getOwnerDataById($first_user['uid']);
} else {
$owner = User::getOwnerDataById($item['uid']);
@ -4200,7 +4200,7 @@ class Diaspora
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
dba::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
DBA::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora like signature');
return true;
@ -4236,7 +4236,7 @@ class Diaspora
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
DBA::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora comment signature');
return true;

View file

@ -13,7 +13,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Lock;
use Friendica\Core\System;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
@ -78,7 +78,7 @@ class OStatus
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
$contact = dba::selectFirst('contact', [], $condition);
$contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBM::is_result($contact) && $author["author-link"] != '') {
@ -89,14 +89,14 @@ class OStatus
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
NETWORK_STATUSNET, CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
$contact = dba::selectFirst('contact', [], $condition);
$contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBM::is_result($contact) && ($addr != '')) {
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $addr, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
$contact = dba::selectFirst('contact', [], $condition);
$contact = DBA::selectFirst('contact', [], $condition);
}
if (DBM::is_result($contact)) {
@ -182,7 +182,7 @@ class OStatus
$contact['name-date'] = DateTimeFormat::utcNow();
dba::update('contact', $contact, ['id' => $contact["id"]], $current);
DBA::update('contact', $contact, ['id' => $contact["id"]], $current);
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
@ -194,7 +194,7 @@ class OStatus
if ($cid) {
$fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
$old_contact = dba::selectFirst('contact', $fields, ['id' => $cid]);
$old_contact = DBA::selectFirst('contact', $fields, ['id' => $cid]);
// Update it with the current values
$fields = ['url' => $author["author-link"], 'name' => $contact["name"],
@ -203,7 +203,7 @@ class OStatus
'about' => $contact["about"], 'location' => $contact["location"],
'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
dba::update('contact', $fields, ['id' => $cid], $old_contact);
DBA::update('contact', $fields, ['id' => $cid], $old_contact);
// Update the avatar
if (!empty($author["author-avatar"])) {
@ -834,9 +834,9 @@ class OStatus
$conv_data['source'] = $doc2->saveXML();
$condition = ['item-uri' => $conv_data['uri'],'protocol' => PROTOCOL_OSTATUS_FEED];
if (dba::exists('conversation', $condition)) {
if (DBA::exists('conversation', $condition)) {
logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG);
dba::delete('conversation', ['item-uri' => $conv_data['uri']]);
DBA::delete('conversation', ['item-uri' => $conv_data['uri']]);
}
logger('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG);
@ -858,7 +858,7 @@ class OStatus
private static function fetchSelf($self, &$item)
{
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
if (dba::exists('conversation', $condition)) {
if (DBA::exists('conversation', $condition)) {
logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG);
return;
}
@ -893,7 +893,7 @@ class OStatus
private static function fetchRelated($related, $related_uri, $importer)
{
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
$conversation = dba::selectFirst('conversation', ['source', 'protocol'], $condition);
$conversation = DBA::selectFirst('conversation', ['source', 'protocol'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
$xml = $conversation['source'];
@ -903,7 +903,7 @@ class OStatus
}
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
dba::delete('conversation', ['item-uri' => $related_uri]);
DBA::delete('conversation', ['item-uri' => $related_uri]);
}
}
@ -973,7 +973,7 @@ class OStatus
// Finally we take the data that we fetched from "ostatus:conversation"
if ($xml == '') {
$condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
$conversation = dba::selectFirst('conversation', ['source'], $condition);
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
@ -1300,7 +1300,7 @@ class OStatus
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
$condition = ['uid' => $owner['uid'], 'self' => false, 'pending' => false,
'archive' => false, 'hidden' => false, 'blocked' => false];
$members = dba::count('contact', $condition);
$members = DBA::count('contact', $condition);
XML::addElement($doc, $root, "statusnet:group_info", "", ["member_count" => $members]);
}
@ -1401,7 +1401,7 @@ class OStatus
*/
private static function addAuthor($doc, $owner, $show_profile = true)
{
$profile = dba::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
$profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
$author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
@ -1981,7 +1981,7 @@ class OStatus
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
$conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
if (DBM::is_result($conversation)) {
if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
@ -2022,7 +2022,7 @@ class OStatus
foreach ($mentioned as $mention) {
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($mention)];
$contact = dba::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
$contact = DBA::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == ACCOUNT_TYPE_COMMUNITY) ||
($contact['self'] && ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY))) {
XML::addElement($doc, $entry, "link", "",

View file

@ -15,7 +15,7 @@ use Exception;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
@ -67,7 +67,7 @@ class PortableContact
if ($cid) {
if (!$url || !$uid) {
$contact = dba::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
$contact = DBA::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
if (DBM::is_result($contact)) {
$url = $contact['poco'];
$uid = $contact['uid'];
@ -204,7 +204,7 @@ class PortableContact
logger("load: loaded $total entries", LOGGER_DEBUG);
$condition = ["`cid` = ? AND `uid` = ? AND `zcid` = ? AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", $cid, $uid, $zcid];
dba::delete('glink', $condition);
DBA::delete('glink', $condition);
}
public static function reachable($profile, $server = "", $network = "", $force = false)
@ -342,7 +342,7 @@ class PortableContact
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
if ($force) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
logger("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG);
@ -423,7 +423,7 @@ class PortableContact
if (!empty($noscrape["updated"])) {
$fields = ['last_contact' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@ -451,7 +451,7 @@ class PortableContact
&& (normalise_link($profile) != normalise_link($data["url"]))
) {
// Delete the old entry
dba::delete('gcontact', ['nurl' => normalise_link($profile)]);
DBA::delete('gcontact', ['nurl' => normalise_link($profile)]);
$gcontact = array_merge($gcontacts[0], $data);
@ -472,7 +472,7 @@ class PortableContact
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
return false;
@ -488,7 +488,7 @@ class PortableContact
if (!$feedret["success"]) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
return false;
@ -530,11 +530,11 @@ class PortableContact
$fields['updated'] = $last_updated;
}
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
if (($gcontacts[0]["generation"] == 0)) {
$fields = ['generation' => 9];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
logger("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG);
@ -930,12 +930,12 @@ class PortableContact
return false;
}
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
$gserver = DBA::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
if (DBM::is_result($gserver)) {
if ($gserver["created"] <= NULL_DATE) {
$fields = ['created' => DateTimeFormat::utcNow()];
$condition = ['nurl' => normalise_link($server_url)];
dba::update('gserver', $fields, $condition);
DBA::update('gserver', $fields, $condition);
}
$poco = $gserver["poco"];
$noscrape = $gserver["noscrape"];
@ -989,7 +989,7 @@ class PortableContact
// Mastodon uses the "@" for user profiles.
// But this can be misunderstood.
if (parse_url($server_url, PHP_URL_USER) != '') {
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1005,7 +1005,7 @@ class PortableContact
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
(!$serverret["success"] && ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT))) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1020,7 +1020,7 @@ class PortableContact
// Quit if there is a timeout
if (!$serverret["success"] && ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1046,7 +1046,7 @@ class PortableContact
if (!$failure) {
// This will be too low, but better than no value at all.
$registered_users = dba::count('gcontact', ['server_url' => normalise_link($server_url)]);
$registered_users = DBA::count('gcontact', ['server_url' => normalise_link($server_url)]);
}
// Look for poco
@ -1365,7 +1365,7 @@ class PortableContact
}
// Check again if the server exists
$found = dba::exists('gserver', ['nurl' => normalise_link($server_url)]);
$found = DBA::exists('gserver', ['nurl' => normalise_link($server_url)]);
$version = strip_tags($version);
$site_name = strip_tags($site_name);
@ -1379,11 +1379,11 @@ class PortableContact
'last_contact' => $last_contact, 'last_failure' => $last_failure];
if ($found) {
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
DBA::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
} elseif (!$failure) {
$fields['nurl'] = normalise_link($server_url);
$fields['created'] = DateTimeFormat::utcNow();
dba::insert('gserver', $fields);
DBA::insert('gserver', $fields);
}
if (!$failure && in_array($fields['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
@ -1414,17 +1414,17 @@ class PortableContact
return;
}
$gserver = dba::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => normalise_link($server_url)]);
$gserver = DBA::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => normalise_link($server_url)]);
if (!DBM::is_result($gserver)) {
return;
}
if (($gserver['relay-subscribe'] != $data->subscribe) || ($gserver['relay-scope'] != $data->scope)) {
$fields = ['relay-subscribe' => $data->subscribe, 'relay-scope' => $data->scope];
dba::update('gserver', $fields, ['id' => $gserver['id']]);
DBA::update('gserver', $fields, ['id' => $gserver['id']]);
}
dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
DBA::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
if ($data->scope == 'tags') {
// Avoid duplicates
$tags = [];
@ -1434,7 +1434,7 @@ class PortableContact
}
foreach ($tags as $tag) {
dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag], true);
DBA::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag], true);
}
}
@ -1620,7 +1620,7 @@ class PortableContact
}
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return true;
} else {
@ -1629,7 +1629,7 @@ class PortableContact
// If we couldn't reach the server, we will try it some time later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return false;
}
@ -1655,7 +1655,7 @@ class PortableContact
if (!self::checkServer($server["url"], $server["network"])) {
// The server is not reachable? Okay, then we will try it later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
continue;
}