Browse Source

Rename selectOne to selectFirst

pull/4194/head
Hypolite Petovan 4 years ago
parent
commit
ae66bcaff3
51 changed files with 821 additions and 821 deletions
  1. +4
    -4
      include/api.php
  2. +2
    -2
      include/contact_widgets.php
  3. +2
    -2
      include/conversation.php
  4. +2
    -2
      include/dba.php
  5. +4
    -4
      include/enotify.php
  6. +1
    -1
      include/identity.php
  7. +3
    -3
      include/items.php
  8. +2
    -2
      include/message.php
  9. +1
    -1
      include/nav.php
  10. +1
    -1
      include/session.php
  11. +1
    -1
      include/tags.php
  12. +1
    -1
      index.php
  13. +1
    -1
      mod/admin.php
  14. +1
    -1
      mod/cal.php
  15. +2
    -2
      mod/common.php
  16. +6
    -6
      mod/contacts.php
  17. +2
    -2
      mod/display.php
  18. +1
    -1
      mod/hovercard.php
  19. +4
    -4
      mod/network.php
  20. +2
    -2
      mod/noscrape.php
  21. +1
    -1
      mod/proxy.php
  22. +1
    -1
      mod/receive.php
  23. +1
    -1
      mod/settings.php
  24. +2
    -2
      mod/unfollow.php
  25. +1
    -1
      mod/xrd.php
  26. +404
    -404
      src/Content/OEmbed.php
  27. +1
    -1
      src/Core/Cache.php
  28. +1
    -1
      src/Core/Config.php
  29. +1
    -1
      src/Core/PConfig.php
  30. +1
    -1
      src/Core/Worker.php
  31. +15
    -15
      src/Model/Contact.php
  32. +1
    -1
      src/Model/GContact.php
  33. +4
    -4
      src/Model/Group.php
  34. +3
    -3
      src/Model/Photo.php
  35. +4
    -4
      src/Model/User.php
  36. +306
    -306
      src/Module/Login.php
  37. +2
    -2
      src/Network/FKOAuth1.php
  38. +1
    -1
      src/Network/FKOAuthDataStore.php
  39. +2
    -2
      src/Network/Probe.php
  40. +1
    -1
      src/Object/Post.php
  41. +4
    -4
      src/Protocol/Diaspora.php
  42. +1
    -1
      src/Protocol/Feed.php
  43. +7
    -7
      src/Protocol/OStatus.php
  44. +2
    -2
      src/Protocol/PortableContact.php
  45. +1
    -1
      src/Util/ExAuth.php
  46. +1
    -1
      src/Util/Lock.php
  47. +1
    -1
      src/Worker/Expire.php
  48. +1
    -1
      src/Worker/Notifier.php
  49. +4
    -4
      src/Worker/OnePoll.php
  50. +2
    -2
      src/Worker/Queue.php
  51. +1
    -1
      util/global_community_silence.php

+ 4
- 4
include/api.php View File

@ -222,7 +222,7 @@ function api_login(App $a)
} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id) {
$record = dba::selectOne('user', [], ['uid' => $user_id]);
$record = dba::selectFirst('user', [], ['uid' => $user_id]);
}
}
@ -473,7 +473,7 @@ function api_rss_extra(App $a, $arr, $user_info)
*/
function api_unique_id_to_nurl($id)
{
$r = dba::selectOne('contact', array('nurl'), array('uid' => 0, 'id' => $id));
$r = dba::selectFirst('contact', array('nurl'), array('uid' => 0, 'id' => $id));
if (DBM::is_result($r)) {
return $r["nurl"];
@ -792,7 +792,7 @@ function api_get_user(App $a, $contact_id = null)
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
$theme_info = dba::selectOne('user', ['theme'], ['uid' => $ret['uid']]);
$theme_info = dba::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
if ($schema && ($schema != '---')) {
@ -4870,7 +4870,7 @@ function api_friendica_remoteauth()
// traditional DFRN
$r = dba::selectOne('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
$r = dba::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($r) || ($r['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");


+ 2
- 2
include/contact_widgets.php View File

@ -224,12 +224,12 @@ function common_friends_visitor_widget($profile_uid)
if (!$cid) {
if (get_my_url()) {
$r = dba::selectOne('contact', ['id'],
$r = dba::selectFirst('contact', ['id'],
['nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid]);
if (DBM::is_result($r)) {
$cid = $r['id'];
} else {
$r = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
$r = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
if (DBM::is_result($r)) {
$zcid = $r['id'];
}


+ 2
- 2
include/conversation.php View File

@ -968,7 +968,7 @@ function best_link_url($item, &$sparkle, $url = '') {
$clean_url = normalise_link($item['author-link']);
if (local_user()) {
$r = dba::selectOne('contact', ['id'],
$r = dba::selectFirst('contact', ['id'],
['network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false]);
if (DBM::is_result($r)) {
$best_url = 'redir/' . $r['id'];
@ -1019,7 +1019,7 @@ function item_photo_menu($item) {
$cid = 0;
$network = '';
$rel = 0;
$r = dba::selectOne('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])));
$r = dba::selectFirst('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])));
if (DBM::is_result($r)) {
$cid = $r['id'];
$network = $r['network'];


+ 2
- 2
include/dba.php View File

@ -1047,7 +1047,7 @@ class dba {
if (is_bool($old_fields)) {
$do_insert = $old_fields;
$old_fields = self::selectOne($table, [], $condition);
$old_fields = self::selectFirst($table, [], $condition);
if (is_bool($old_fields)) {
if ($do_insert) {
@ -1095,7 +1095,7 @@ class dba {
* @return bool|array
* @see dba::select
*/
public static function selectOne($table, array $fields = [], array $condition = [], $params = [])
public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{
$params['limit'] = 1;
$result = self::select($table, $fields, $condition, $params);


+ 4
- 4
include/enotify.php View File

@ -106,7 +106,7 @@ function notification($params)
}
if ($params['type'] == NOTIFY_COMMENT) {
$p = dba::selectOne('thread', ['ignored'], ['iid' => $parent_id]);
$p = dba::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($p) && $p["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
@ -131,7 +131,7 @@ function notification($params)
$p = null;
if ($params['otype'] === 'item' && $parent_id) {
$p = dba::selectOne('item', [], ['id' => $parent_id]);
$p = dba::selectFirst('item', [], ['id' => $parent_id]);
}
$item_post_type = item_post_type($p);
@ -672,12 +672,12 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles = $notification_data["profiles"];
$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
$user = dba::selectOne('user', $fields, ['uid' => $uid]);
$user = dba::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
$owner = dba::selectOne('contact', ['url'], ['self' => true, 'uid' => $uid]);
$owner = dba::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
return false;
}


+ 1
- 1
include/identity.php View File

@ -162,7 +162,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0)
if (remote_user() && count($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $uid) {
$r = dba::selectOne('contact', ['profile-id'], ['id' => $visitor['cid']]);
$r = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
if (DBM::is_result($r)) {
$profile = $r['profile-id'];
}


+ 3
- 3
include/items.php View File

@ -562,7 +562,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
// check for create date and expire time
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
$user = dba::selectOne('user', ['expire'], ['uid' => $uid]);
$user = dba::selectFirst('user', ['expire'], ['uid' => $uid]);
if (DBM::is_result($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
$expire_interval = $user['expire'];
}
@ -1149,14 +1149,14 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
*/
function item_set_last_item($arr) {
// Unarchive the author
$contact = dba::selectOne('contact', [], ['id' => $arr["author-link"]]);
$contact = dba::selectFirst('contact', [], ['id' => $arr["author-link"]]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}
// Unarchive the contact if it is a toplevel posting
if ($arr["parent-uri"] === $arr["uri"]) {
$contact = dba::selectOne('contact', [], ['id' => $arr["contact-id"]]);
$contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"]]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}


+ 2
- 2
include/message.php View File

@ -69,7 +69,7 @@ function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
$r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => local_user()]);
$r = dba::selectFirst('conv', ['id'], ['guid' => $conv_guid, 'uid' => local_user()]);
if (DBM::is_result($r)) {
$convid = $r['id'];
}
@ -188,7 +188,7 @@ function send_wallmessage($recipient = '', $body = '', $subject = '', $replyto =
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
$r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => $recipient['uid']]);
$r = dba::selectFirst('conv', ['id'], ['guid' => $conv_guid, 'uid' => $recipient['uid']]);
if (!DBM::is_result($r)) {
logger('send message: conversation not found.');
return -4;


+ 1
- 1
include/nav.php View File

@ -94,7 +94,7 @@ function nav_info(App $a)
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
// user info
$r = dba::selectOne('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$r = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = array(
'icon' => (DBM::is_result($r) ? $a->remove_baseurl($r['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'],


+ 1
- 1
include/session.php View File

@ -33,7 +33,7 @@ function ref_session_read($id)
return '';
}
$r = dba::selectOne('session', ['data'], ['sid' => $id]);
$r = dba::selectFirst('session', ['data'], ['sid' => $id]);
if (DBM::is_result($r)) {
$session_exists = true;
return $r['data'];


+ 1
- 1
include/tags.php View File

@ -226,7 +226,7 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
$o = '';
$r = tagadelic($uid, $count, $owner_id, $flags, $type);
if (count($r)) {
$contact = dba::selectOne('contact', ['url'], ['id' => $uid]);
$contact = dba::selectFirst('contact', ['url'], ['id' => $uid]);
$url = System::removedBaseUrl($contact['url']);
foreach ($r as $rr) {


+ 1
- 1
index.php View File

@ -108,7 +108,7 @@ if (!$a->is_backend()) {
*/
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we didn't loaded user data yet, but we need user language
$r = dba::selectOne('user', ['language'], ['uid' => $_SESSION['uid']]);
$r = dba::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
if (DBM::is_result($r)) {
$_SESSION['language'] = $r['language'];


+ 1
- 1
mod/admin.php View File

@ -1551,7 +1551,7 @@ function admin_page_users(App $a)
{
if ($a->argc > 2) {
$uid = $a->argv[3];
$user = dba::selectOne('user', ['username', 'blocked'], ['uid' => $uid]);
$user = dba::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (DBM::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');


+ 1
- 1
mod/cal.php View File

@ -32,7 +32,7 @@ function cal_init(App $a)
if ($a->argc > 1) {
$nick = $a->argv[1];
$user = dba::selectOne('user', [], ['nickname' => $nick, 'blocked' => false]);
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBM::is_result($user)) {
return;
}


+ 2
- 2
mod/common.php View File

@ -63,11 +63,11 @@ function common_content(App $a)
}
if (!$cid && get_my_url()) {
$contact = dba::selectOne('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
$contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
$gcontact = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
$gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}


+ 6
- 6
mod/contacts.php View File

@ -33,7 +33,7 @@ function contacts_init(App $a)
$contact = [];
if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}
if (DBM::is_result($contact)) {
@ -222,7 +222,7 @@ function contacts_post(App $a)
notice(t('Failed to update contact record.') . EOL);
}
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$a->data['contact'] = $contact;
}
@ -233,7 +233,7 @@ function contacts_post(App $a)
function _contact_update($contact_id)
{
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -254,7 +254,7 @@ function _contact_update($contact_id)
function _contact_update_profile($contact_id)
{
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -389,7 +389,7 @@ function contacts_content(App $a)
$cmd = $a->argv[2];
$orig_record = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
$orig_record = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
if (!DBM::is_result($orig_record)) {
notice(t('Could not access contact record.') . EOL);
goaway('contacts');
@ -904,7 +904,7 @@ function contact_posts($a, $contact_id)
{
$o = contacts_tab($a, $contact_id, 1);
$contact = dba::selectOne('contact', ['url'], ['id' => $contact_id]);
$contact = dba::selectFirst('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));


+ 2
- 2
mod/display.php View File

@ -202,7 +202,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
if ($update) {
$item_id = $_REQUEST['item_id'];
$item = dba::selectOne('item', ['uid', 'parent'], ['id' => $item_id]);
$item = dba::selectFirst('item', ['uid', 'parent'], ['id' => $item_id]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
$item_parent = $item['parent'];
} else {
@ -345,7 +345,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
$s = dba::inArray($r);
if (local_user() && (local_user() == $a->profile['uid'])) {
$unseen = dba::selectOne('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
$unseen = dba::selectFirst('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
if (DBM::is_result($unseen)) {
dba::update('item', array('unseen' => false), array('parent' => $s[0]['parent'], 'unseen' => true));
}


+ 1
- 1
mod/hovercard.php View File

@ -44,7 +44,7 @@ function hovercard_content()
$cid = 0;
if (local_user() && strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
$r = dba::selectOne('contact', ['nurl'], ['id' => $cid]);
$r = dba::selectFirst('contact', ['nurl'], ['id' => $cid]);
$profileurl = defaults($r, 'nurl', '');
}


+ 4
- 4
mod/network.php View File

@ -581,7 +581,7 @@ function networkThreadedView(App $a, $update = 0) {
if ($cid) {
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
$condition = ["`id` = ? AND (`forum` OR `prv`)", $cid];
$contact = dba::selectOne('contact', ['addr', 'nick'], $condition);
$contact = dba::selectFirst('contact', ['addr', 'nick'], $condition);
if (DBM::is_result($contact)) {
if ($contact["addr"] != '') {
$content = "!".$contact["addr"];
@ -632,7 +632,7 @@ function networkThreadedView(App $a, $update = 0) {
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
if ($group) {
$r = dba::selectOne('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
$r = dba::selectFirst('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
if (!DBM::is_result($r)) {
if ($update)
killme();
@ -647,7 +647,7 @@ function networkThreadedView(App $a, $update = 0) {
$contact_str_self = "";
$contact_str = implode(',',$contacts);
$self = dba::selectOne('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
$self = dba::selectFirst('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($self)) {
$contact_str_self = $self["id"];
}
@ -668,7 +668,7 @@ function networkThreadedView(App $a, $update = 0) {
$fields = ['id', 'name', 'network', 'writable', 'nurl',
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location'];
$condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid];
$r = dba::selectOne('contact', $fields, $condition);
$r = dba::selectFirst('contact', $fields, $condition);
if (DBM::is_result($r)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);


+ 2
- 2
mod/noscrape.php View File

@ -68,13 +68,13 @@ function noscrape_init(App $a) {
// We display the last activity (post or login), reduced to year and week number
$last_active = 0;
$condition = ['uid' => $a->profile['uid'], 'self' => true];
$contact = dba::selectOne('contact', ['last-item'], $condition);
$contact = dba::selectFirst('contact', ['last-item'], $condition);
if (DBM::is_result($contact)) {
$last_active = strtotime($contact['last-item']);
}
$condition = ['uid' => $a->profile['uid']];
$user = dba::selectOne('user', ['login_date'], $condition);
$user = dba::selectFirst('user', ['login_date'], $condition);
if (DBM::is_result($user)) {
if ($last_active < strtotime($user['login_date'])) {
$last_active = strtotime($user['login_date']);


+ 1
- 1
mod/proxy.php View File

@ -148,7 +148,7 @@ function proxy_init(App $a) {
$r = array();
if (!$direct_cache && ($cachefile == '')) {
$r = dba::selectOne('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
$r = dba::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
if (DBM::is_result($r)) {
$img_str = $r['data'];
$mime = $r['desc'];


+ 1
- 1
mod/receive.php View File

@ -32,7 +32,7 @@ function receive_post(App $a)
}
$guid = $a->argv[2];
$importer = dba::selectOne('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
$importer = dba::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($importer)) {
http_status_exit(500);
}


+ 1
- 1
mod/settings.php View File

@ -997,7 +997,7 @@ function settings_content(App $a)
require_once('include/acl_selectors.php');
$profile = dba::selectOne('profile', [], ['is-default' => true, 'uid' => local_user()]);
$profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
if (!DBM::is_result($profile)) {
notice(t('Unable to find your profile. Please contact your admin.') . EOL);
return;


+ 2
- 2
mod/unfollow.php View File

@ -26,7 +26,7 @@ function unfollow_post(App $a) {
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
$uid, CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = dba::selectOne('contact', [], $condition);
$contact = dba::selectFirst('contact', [], $condition);
if (!DBM::is_result($contact)) {
notice(t("Contact wasn't found or can't be unfollowed."));
@ -65,7 +65,7 @@ function unfollow_content(App $a) {
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
local_user(), CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = dba::selectOne('contact', ['url', 'network', 'addr', 'name'], $condition);
$contact = dba::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBM::is_result($contact)) {
notice(t("You aren't a friend of this contact.").EOL);


+ 1
- 1
mod/xrd.php View File

@ -36,7 +36,7 @@ function xrd_init(App $a)
$name = substr($local, 0, strpos($local, '@'));
}
$r = dba::selectOne('user', [], ['nickname' => $name]);
$r = dba::selectFirst('user', [], ['nickname' => $name]);
if (!DBM::is_result($r)) {
killme();
}


+ 404
- 404
src/Content/OEmbed.php View File

@ -1,404 +1,404 @@
<?php
/**
* @file src/Content/OEmbed.php
*/
namespace Friendica\Content;
use Friendica\Core\Cache;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Util\ParseUrl;
use dba;
use DOMDocument;
use DOMXPath;
use DOMNode;
use Exception;
require_once 'include/dba.php';
require_once 'mod/proxy.php';
/**
* Handles all OEmbed content fetching and replacement
*
* OEmbed is a standard used to allow an embedded representation of a URL on
* third party sites
*
* @see https://oembed.com
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class OEmbed
{
public static function replaceCallback($matches)
{
$embedurl = $matches[1];
$j = self::fetchURL($embedurl);
$s = self::formatObject($j);
return $s;
}
/**
* @brief Get data from an URL to embed its content.
*
* @param string $embedurl The URL from which the data should be fetched.
* @param bool $no_rich_type If set to true rich type content won't be fetched.
*
* @return bool|object Returns object with embed content or false if no embedable
* content exists
*/
public static function fetchURL($embedurl, $no_rich_type = false)
{
$embedurl = trim($embedurl, "'");
$embedurl = trim($embedurl, '"');
$a = get_app();
$condition = ['url' => normalise_link($embedurl)];
$r = dba::selectOne('oembed', ['content'], $condition);
if (DBM::is_result($r)) {
$txt = $r["content"];
} else {
$txt = Cache::get($a->videowidth . $embedurl);
}
// These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source
$noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
$ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
if (is_null($txt)) {
$txt = "";
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
$redirects = 0;
$html_text = fetch_url($embedurl, false, $redirects, 15, "text/*");
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
$xpath = new DOMXPath($dom);
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
break;
}
$entries = $xpath->query("//link[@type='text/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
break;
}
}
}
}
$txt = trim($txt);
if (!$txt || $txt[0] != "{") {
$txt = '{"type":"error"}';
} else { //save in cache
$j = json_decode($txt);
if ($j->type != "error") {
dba::insert('oembed', array('url' => normalise_link($embedurl),
'content' => $txt, 'created' => datetime_convert()), true);
}
Cache::set($a->videowidth . $embedurl, $txt, CACHE_DAY);
}
}
$j = json_decode($txt);
if (!is_object($j)) {
return false;
}
// Always embed the SSL version
if (isset($j->html)) {
$j->html = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), array("https://www.youtube.com/", "https://player.vimeo.com/"), $j->html);
}
$j->embedurl = $embedurl;
// If fetching information doesn't work, then improve via internal functions
if (($j->type == "error") || ($no_rich_type && ($j->type == "rich"))) {
$data = ParseUrl::getSiteinfoCached($embedurl, true, false);
$j->type = $data["type"];
if ($j->type == "photo") {
$j->url = $data["url"];
//$j->width = $data["images"][0]["width"];
//$j->height = $data["images"][0]["height"];
}
if (isset($data["title"])) {
$j->title = $data["title"];
}
if (isset($data["text"])) {
$j->description = $data["text"];
}
if (is_array($data["images"])) {
$j->thumbnail_url = $data["images"][0]["src"];
$j->thumbnail_width = $data["images"][0]["width"];
$j->thumbnail_height = $data["images"][0]["height"];
}
}
call_hooks('oembed_fetch_url', $embedurl, $j);
return $j;
}
public static function formatObject($j)
{
$embedurl = $j->embedurl;
$jhtml = $j->html;
$ret = '<div class="oembed ' . $j->type . '">';
switch ($j->type) {
case "video":
if (isset($j->thumbnail_url)) {
$tw = (isset($j->thumbnail_width) && intval($j->thumbnail_width)) ? $j->thumbnail_width : 200;
$th = (isset($j->thumbnail_height) && intval($j->thumbnail_height)) ? $j->thumbnail_height : 180;
// make sure we don't attempt divide by zero, fallback is a 1:1 ratio
$tr = (($th) ? $tw / $th : 1);
$th = 120;
$tw = $th * $tr;
$tpl = get_markup_template('oembed_video.tpl');
$ret .= replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
'$embedurl' => $embedurl,
'$escapedhtml' => base64_encode($jhtml),
'$tw' => $tw,
'$th' => $th,
'$turl' => $j->thumbnail_url,
));
} else {
$ret = $jhtml;
}
break;
case "photo":
$ret .= '<img width="' . $j->width . '" src="' . proxy_url($j->url) . '">';
break;
case "link":
break;
case "rich":
if (self::isAllowedURL($embedurl)) {
$ret .= proxy_parse_html($jhtml);
}
break;
}
$ret .= '</div>';
// add link to source if not present in "rich" type
if ($j->type != 'rich' || !strpos($j->html, $embedurl)) {
$ret .= '<h4>';
if (isset($j->title)) {
if (isset($j->provider_name)) {
$ret .= $j->provider_name . ": ";
}
$embedlink = (isset($j->title)) ? $j->title : $embedurl;
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $embedlink . '</a>';
if (isset($j->author_name)) {
$ret .= ' (' . $j->author_name . ')';
}
} elseif (isset($j->provider_name) || isset($j->author_name)) {
$embedlink = "";
if (isset($j->provider_name)) {
$embedlink .= $j->provider_name;
}
if (isset($j->author_name)) {
if ($embedlink != "") {
$embedlink .= ": ";
}
$embedlink .= $j->author_name;
}
if (trim($embedlink) == "") {
$embedlink = $embedurl;
}
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $embedlink . '</a>';
}
$ret .= "</h4>";
} elseif (!strpos($j->html, $embedurl)) {
// add <a> for html2bbcode conversion
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $j->title . '</a>';
}
$ret = str_replace("\n", "", $ret);
return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
}
public static function BBCode2HTML($text)
{
$stopoembed = Config::get("system", "no_oembed");
if ($stopoembed == true) {
return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "<!-- oembed $1 --><i>" . t('Embedding disabled') . " : $1</i><!-- /oembed $1 -->", $text);
}
return preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", ['self', 'replaceCallback'], $text);
}
/**
* Find <span class='oembed'>..<a href='url' rel='oembed'>..</a></span>
* and replace it with [embed]url[/embed]
*/
public static function HTML2BBCode($text)
{
// start parser only if 'oembed' is in text
if (strpos($text, "oembed")) {
// convert non ascii chars to html entities
$html_text = mb_convert_encoding($text, 'HTML-ENTITIES', mb_detect_encoding($text));
// If it doesn't parse at all, just return the text.
$dom = @DOMDocument::loadHTML($html_text);
if (!$dom) {
return $text;
}
$xpath = new DOMXPath($dom);
$xattr = self::buildXPath("class", "oembed");
$entries = $xpath->query("//div[$xattr]");
$xattr = "@rel='oembed'"; //oe_build_xpath("rel","oembed");
foreach ($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if (!is_null($href)) {
$e->parentNode->replaceChild(new DOMText("[embed]" . $href . "[/embed]"), $e);
}
}
return self::getInnerHTML($dom->getElementsByTagName("body")->item(0));
} else {
return $text;
}
}
/**
* Determines if rich content OEmbed is allowed for the provided URL
*
* @brief Determines if rich content OEmbed is allowed for the provided URL
* @param string $url
* @return boolean
*/
public static function isAllowedURL($url)
{
if (!Config::get('system', 'no_oembed_rich_content')) {
return true;
}
$domain = parse_url($url, PHP_URL_HOST);
if (!x($domain)) {
return false;
}
$str_allowed = Config::get('system', 'allowed_oembed', '');
if (!x($str_allowed)) {
return false;
}
$allowed = explode(',', $str_allowed);
return allowed_domain($domain, $allowed);
}
public static function getHTML($url, $title = null)
{
// Always embed the SSL version
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
$o = OEmbed::fetchURL($url);
if (!is_object($o) || $o->type == 'error') {
throw new Exception('OEmbed failed for URL: ' . $url);
}
if (x($title)) {
$o->title = $title;
}
$html = OEmbed::formatObject($o);
return $html;
}
/**
* @brief Generates the iframe HTML for an oembed attachment.
*
* Width and height are given by the remote, and are regularly too small for
* the generated iframe.
*
* The width is entirely discarded for the actual width of the post, while fixed
* height is used as a starting point before the inevitable resizing.
*
* Since the iframe is automatically resized on load, there are no need for ugly
* and impractical scrollbars.
*
* @todo This function is currently unused until someone™ adds support for a separate OEmbed domain
*
* @param string $src Original remote URL to embed
* @param string $width
* @param string $height
* @return string formatted HTML
*
* @see oembed_format_object()
*/
private static function iframe($src, $width, $height)
{
$a = get_app();
if (!$height || strstr($height, '%')) {
$height = '200';
}
$width = '100%';
$src = System::baseUrl() . '/oembed/' . base64url_encode($src);
return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $src . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
}
/**
* Generates an XPath query to select elements whose provided attribute contains
* the provided value in a space-separated list.
*
* @brief Generates attribute search XPath string
*
* @param string $attr Name of the attribute to seach
* @param string $value Value to search in a space-separated list
* @return string
*/
private static function buildXPath($attr, $value)
{
// https://www.westhoffswelt.de/blog/2009/6/9/select-html-elements-with-more-than-one-css-class-using-xpath
return "contains(normalize-space(@$attr), ' $value ') or substring(normalize-space(@$attr), 1, string-length('$value') + 1) = '$value ' or substring(normalize-space(@$attr), string-length(@$attr) - string-length('$value')) = ' $value' or @$attr = '$value'";
}
/**
* Returns the inner XML string of a provided DOMNode
*
* @brief Returns the inner XML string of a provided DOMNode
*
* @param DOMNode $node
* @return string
*/
private static function getInnerHTML(DOMNode $node)
{
$innerHTML = '';
$children = $node->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML($child);
}
return $innerHTML;
}
}
<?php
/**
* @file src/Content/OEmbed.php
*/
namespace Friendica\Content;
use Friendica\Core\Cache;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Util\ParseUrl;
use dba;
use DOMDocument;
use DOMXPath;
use DOMNode;
use Exception;
require_once 'include/dba.php';
require_once 'mod/proxy.php';
/**
* Handles all OEmbed content fetching and replacement
*
* OEmbed is a standard used to allow an embedded representation of a URL on
* third party sites
*
* @see https://oembed.com
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class OEmbed
{
public static function replaceCallback($matches)
{
$embedurl = $matches[1];
$j = self::fetchURL($embedurl);
$s = self::formatObject($j);
return $s;
}
/**
* @brief Get data from an URL to embed its content.
*
* @param string $embedurl The URL from which the data should be fetched.
* @param bool $no_rich_type If set to true rich type content won't be fetched.
*
* @return bool|object Returns object with embed content or false if no embedable
* content exists
*/
public static function fetchURL($embedurl, $no_rich_type = false)
{
$embedurl = trim($embedurl, "'");
$embedurl = trim($embedurl, '"');
$a = get_app();
$condition = ['url' => normalise_link($embedurl)];
$r = dba::selectFirst('oembed', ['content'], $condition);
if (DBM::is_result($r)) {
$txt = $r["content"];
} else {
$txt = Cache::get($a->videowidth . $embedurl);
}
// These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source
$noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
$ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
if (is_null($txt)) {
$txt = "";
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
$redirects = 0;
$html_text = fetch_url($embedurl, false, $redirects, 15, "text/*");
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
$xpath = new DOMXPath($dom);
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
break;
}
$entries = $xpath->query("//link[@type='text/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
break;
}
}
}
}
$txt = trim($txt);
if (!$txt || $txt[0] != "{") {
$txt = '{"type":"error"}';
} else { //save in cache
$j = json_decode($txt);
if ($j->type != "error") {
dba::insert('oembed', array('url' => normalise_link($embedurl),
'content' => $txt, 'created' => datetime_convert()), true);
}
Cache::set($a->videowidth . $embedurl, $txt, CACHE_DAY);
}
}
$j = json_decode($txt);
if (!is_object($j)) {
return false;
}
// Always embed the SSL version
if (isset($j->html)) {
$j->html = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), array("https://www.youtube.com/", "https://player.vimeo.com/"), $j->html);
}
$j->embedurl = $embedurl;
// If fetching information doesn't work, then improve via internal functions
if (($j->type == "error") || ($no_rich_type && ($j->type == "rich"))) {
$data = ParseUrl::getSiteinfoCached($embedurl, true, false);
$j->type = $data["type"];
if ($j->type == "photo") {
$j->url = $data["url"];
//$j->width = $data["images"][0]["width"];
//$j->height = $data["images"][0]["height"];
}
if (isset($data["title"])) {
$j->title = $data["title"];
}
if (isset($data["text"])) {
$j->description = $data["text"];
}
if (is_array($data["images"])) {
$j->thumbnail_url = $data["images"][0]["src"];
$j->thumbnail_width = $data["images"][0]["width"];
$j->thumbnail_height = $data["images"][0]["height"];
}
}
call_hooks('oembed_fetch_url', $embedurl, $j);
return $j;
}
public static function formatObject($j)
{
$embedurl = $j->embedurl;
$jhtml = $j->html;
$ret = '<div class="oembed ' . $j->type . '">';
switch ($j->type) {
case "video":
if (isset($j->thumbnail_url)) {
$tw = (isset($j->thumbnail_width) && intval($j->thumbnail_width)) ? $j->thumbnail_width : 200;
$th = (isset($j->thumbnail_height) && intval($j->thumbnail_height)) ? $j->thumbnail_height : 180;
// make sure we don't attempt divide by zero, fallback is a 1:1 ratio
$tr = (($th) ? $tw / $th : 1);
$th = 120;
$tw = $th * $tr;
$tpl = get_markup_template('oembed_video.tpl');
$ret .= replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
'$embedurl' => $embedurl,
'$escapedhtml' => base64_encode($jhtml),
'$tw' => $tw,
'$th' => $th,
'$turl' => $j->thumbnail_url,
));
} else {
$ret = $jhtml;
}
break;
case "photo":
$ret .= '<img width="' . $j->width . '" src="' . proxy_url($j->url) . '">';
break;
case "link":
break;
case "rich":
if (self::isAllowedURL($embedurl)) {
$ret .= proxy_parse_html($jhtml);
}
break;
}
$ret .= '</div>';
// add link to source if not present in "rich" type
if ($j->type != 'rich' || !strpos($j->html, $embedurl)) {
$ret .= '<h4>';
if (isset($j->title)) {
if (isset($j->provider_name)) {
$ret .= $j->provider_name . ": ";
}
$embedlink = (isset($j->title)) ? $j->title : $embedurl;
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $embedlink . '</a>';
if (isset($j->author_name)) {
$ret .= ' (' . $j->author_name . ')';
}
} elseif (isset($j->provider_name) || isset($j->author_name)) {
$embedlink = "";
if (isset($j->provider_name)) {
$embedlink .= $j->provider_name;
}
if (isset($j->author_name)) {
if ($embedlink != "") {
$embedlink .= ": ";
}
$embedlink .= $j->author_name;
}
if (trim($embedlink) == "") {
$embedlink = $embedurl;
}
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $embedlink . '</a>';
}
$ret .= "</h4>";
} elseif (!strpos($j->html, $embedurl)) {
// add <a> for html2bbcode conversion
$ret .= '<a href="' . $embedurl . '" rel="oembed">' . $j->title . '</a>';
}
$ret = str_replace("\n", "", $ret);
return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
}
public static function BBCode2HTML($text)
{
$stopoembed = Config::get("system", "no_oembed");
if ($stopoembed == true) {
return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "<!-- oembed $1 --><i>" . t('Embedding disabled') . " : $1</i><!-- /oembed $1 -->", $text);
}
return preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", ['self', 'replaceCallback'], $text);
}
/**
* Find <span class='oembed'>..<a href='url' rel='oembed'>..</a></span>
* and replace it with [embed]url[/embed]
*/
public static function HTML2BBCode($text)
{
// start parser only if 'oembed' is in text
if (strpos($text, "oembed")) {
// convert non ascii chars to html entities
$html_text = mb_convert_encoding($text, 'HTML-ENTITIES', mb_detect_encoding($text));
// If it doesn't parse at all, just return the text.
$dom = @DOMDocument::loadHTML($html_text);
if (!$dom) {
return $text;
}
$xpath = new DOMXPath($dom);
$xattr = self::buildXPath("class", "oembed");
$entries = $xpath->query("//div[$xattr]");
$xattr = "@rel='oembed'"; //oe_build_xpath("rel","oembed");
foreach ($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if (!is_null($href)) {
$e->parentNode->replaceChild(new DOMText("[embed]" . $href . "[/embed]"), $e);
}
}
return self::getInnerHTML($dom->getElementsByTagName("body")->item(0));
} else {
return $text;
}
}
/**
* Determines if rich content OEmbed is allowed for the provided URL
*
* @brief Determines if rich content OEmbed is allowed for the provided URL
* @param string $url
* @return boolean
*/
public static function isAllowedURL($url)
{
if (!Config::get('system', 'no_oembed_rich_content')) {
return true;
}
$domain = parse_url($url, PHP_URL_HOST);
if (!x($domain)) {
return false;
}
$str_allowed = Config::get('system', 'allowed_oembed', '');
if (!x($str_allowed)) {
return false;
}
$allowed = explode(',', $str_allowed);
return allowed_domain($domain, $allowed);
}
public static function getHTML($url, $title = null)
{
// Always embed the SSL version
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
$o = OEmbed::fetchURL($url);
if (!is_object($o) || $o->type == 'error') {
throw new Exception('OEmbed failed for URL: ' . $url);
}
if (x($title)) {
$o->title = $title;
}
$html = OEmbed::formatObject($o);
return $html;
}
/**
* @brief Generates the iframe HTML for an oembed attachment.
*
* Width and height are given by the remote, and are regularly too small for
* the generated iframe.
*
* The width is entirely discarded for the actual width of the post, while fixed
* height is used as a starting point before the inevitable resizing.
*
* Since the iframe is automatically resized on load, there are no need for ugly
* and impractical scrollbars.
*
* @todo This function is currently unused until someone™ adds support for a separate OEmbed domain
*
* @param string $src Original remote URL to embed
* @param string $width
* @param string $height
* @return string formatted HTML
*
* @see oembed_format_object()
*/
private static function iframe($src, $width, $height)
{
$a = get_app();
if (!$height || strstr($height, '%')) {
$height = '200';
}
$width = '100%';
$src = System::baseUrl() . '/oembed/' . base64url_encode($src);
return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $src . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
}
/**
* Generates an XPath query to select elements whose provided attribute contains
* the provided value in a space-separated list.
*
* @brief Generates attribute search XPath string
*
* @param string $attr Name of the attribute to seach
* @param string $value Value to search in a space-separated list
* @return string
*/
private static function buildXPath($attr, $value)
{
// https://www.westhoffswelt.de/blog/2009/6/9/select-html-elements-with-more-than-one-css-class-using-xpath
return "contains(normalize-space(@$attr), ' $value ') or substring(normalize-space(@$attr), 1, string-length('$value') + 1) = '$value ' or substring(normalize-space(@$attr), string-length(@$attr) - string-length('$value')) = ' $value' or @$attr = '$value'";
}
/**
* Returns the inner XML string of a provided DOMNode
*
* @brief Returns the inner XML string of a provided DOMNode
*
* @param DOMNode $node
* @return string
*/
private static function getInnerHTML(DOMNode $node)
{
$innerHTML = '';
$children = $node->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML($child);
}
return $innerHTML;
}
}

+ 1
- 1
src/Core/Cache.php View File

@ -109,7 +109,7 @@ class Cache
// Frequently clear cache
self::clear();
$r = dba::selectOne('cache', ['v'], ['k' => $key]);
$r = dba::selectFirst('cache', ['v'], ['k' => $key]);
if (DBM::is_result($r)) {
$cached = $r['v'];


+ 1
- 1
src/Core/Config.php View File

@ -97,7 +97,7 @@ class Config
}
}
$ret = dba::selectOne('config', ['v'], ['cat' => $family, 'k' => $key]);
$ret = dba::selectFirst('config', ['v'], ['cat' => $family, 'k' => $key]);
if (DBM::is_result($ret)) {
// manage array value
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);


+ 1
- 1
src/Core/PConfig.php View File

@ -90,7 +90,7 @@ class PConfig
}
}
$ret = dba::selectOne('pconfig', ['v'], ['uid' => $uid, 'cat' => $family, 'k' => $key]);
$ret = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $family, 'k' => $key]);
if (DBM::is_result($ret)) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
$a->config[$uid][$family][$key] = $val;


+ 1
- 1
src/Core/Worker.php View File

@ -165,7 +165,7 @@ class Worker
private static function highestPriority()
{
$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
$s = dba::selectOne('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
$s = dba::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
if (DBM::is_result($s)) {
return $s["priority"];
} else {


+ 15
- 15
src/Model/Contact.php View File

@ -103,7 +103,7 @@ class Contact extends BaseObject
return true;
}
$user = dba::selectOne('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
$user = dba::selectFirst('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::selectOne('contact', ['uid'], ['id' => $id, 'self' => false]);
$r = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
if (!DBM::is_result($r) || !intval($r[