Browse Source

Rename DBM method calls to DBA method calls

tags/2018.09
Hypolite Petovan Hypolite Petovan <hypolite@mrpetovan.com> 1 year ago
parent
commit
0ec44f3e8a
100 changed files with 463 additions and 526 deletions
  1. +3
    -3
      boot.php
  2. +43
    -44
      include/api.php
  3. +4
    -5
      include/conversation.php
  4. +8
    -9
      include/enotify.php
  5. +4
    -5
      include/items.php
  6. +9
    -10
      include/security.php
  7. +9
    -10
      include/text.php
  8. +1
    -2
      index.php
  9. +2
    -3
      mod/acl.php
  10. +4
    -5
      mod/admin.php
  11. +2
    -3
      mod/allfriends.php
  12. +2
    -2
      mod/api.php
  13. +2
    -3
      mod/attach.php
  14. +3
    -4
      mod/cal.php
  15. +6
    -7
      mod/common.php
  16. +1
    -2
      mod/community.php
  17. +3
    -3
      mod/contactgroup.php
  18. +13
    -14
      mod/contacts.php
  19. +3
    -4
      mod/crepair.php
  20. +6
    -7
      mod/delegate.php
  21. +12
    -13
      mod/dfrn_confirm.php
  22. +5
    -6
      mod/dfrn_notify.php
  23. +11
    -12
      mod/dfrn_poll.php
  24. +10
    -11
      mod/dfrn_request.php
  25. +2
    -3
      mod/directory.php
  26. +2
    -3
      mod/dirfind.php
  27. +9
    -10
      mod/display.php
  28. +3
    -3
      mod/editpost.php
  29. +5
    -5
      mod/events.php
  30. +3
    -3
      mod/fetch.php
  31. +2
    -2
      mod/follow.php
  32. +3
    -3
      mod/friendica.php
  33. +5
    -5
      mod/fsuggest.php
  34. +6
    -6
      mod/group.php
  35. +2
    -2
      mod/ignored.php
  36. +1
    -2
      mod/install.php
  37. +11
    -12
      mod/item.php
  38. +6
    -6
      mod/lockview.php
  39. +3
    -4
      mod/lostpass.php
  40. +10
    -10
      mod/manage.php
  41. +2
    -2
      mod/match.php
  42. +8
    -9
      mod/message.php
  43. +2
    -2
      mod/modexp.php
  44. +3
    -3
      mod/msearch.php
  45. +6
    -7
      mod/network.php
  46. +1
    -1
      mod/nogroup.php
  47. +4
    -5
      mod/noscrape.php
  48. +2
    -3
      mod/notes.php
  49. +2
    -2
      mod/notice.php
  50. +1
    -2
      mod/notifications.php
  51. +2
    -2
      mod/notify.php
  52. +2
    -2
      mod/openid.php
  53. +4
    -4
      mod/photo.php
  54. +23
    -24
      mod/photos.php
  55. +12
    -12
      mod/ping.php
  56. +5
    -5
      mod/poco.php
  57. +4
    -4
      mod/poke.php
  58. +5
    -6
      mod/profile.php
  59. +4
    -5
      mod/profile_photo.php
  60. +14
    -15
      mod/profiles.php
  61. +6
    -6
      mod/profperm.php
  62. +2
    -3
      mod/proxy.php
  63. +5
    -6
      mod/pubsub.php
  64. +2
    -3
      mod/pubsubhubbub.php
  65. +1
    -2
      mod/receive.php
  66. +2
    -3
      mod/redir.php
  67. +4
    -5
      mod/regmod.php
  68. +1
    -2
      mod/removeme.php
  69. +6
    -6
      mod/salmon.php
  70. +3
    -4
      mod/search.php
  71. +17
    -18
      mod/settings.php
  72. +2
    -2
      mod/share.php
  73. +2
    -2
      mod/starred.php
  74. +5
    -5
      mod/subthread.php
  75. +1
    -2
      mod/suggest.php
  76. +6
    -6
      mod/tagger.php
  77. +3
    -3
      mod/tagrm.php
  78. +4
    -4
      mod/uexport.php
  79. +3
    -4
      mod/unfollow.php
  80. +7
    -7
      mod/videos.php
  81. +4
    -4
      mod/viewcontacts.php
  82. +2
    -2
      mod/viewsrc.php
  83. +3
    -4
      mod/wall_attach.php
  84. +3
    -3
      mod/wall_upload.php
  85. +3
    -3
      mod/wallmessage.php
  86. +1
    -2
      mod/xrd.php
  87. +2
    -3
      src/App.php
  88. +2
    -3
      src/Content/ContactSelector.php
  89. +1
    -2
      src/Content/ForumManager.php
  90. +1
    -2
      src/Content/Nav.php
  91. +1
    -2
      src/Content/OEmbed.php
  92. +2
    -3
      src/Content/Widget.php
  93. +1
    -2
      src/Content/Widget/TagCloud.php
  94. +3
    -4
      src/Core/ACL.php
  95. +1
    -2
      src/Core/Addon.php
  96. +1
    -2
      src/Core/Cache/DatabaseCacheDriver.php
  97. +1
    -2
      src/Core/Config/JITConfigAdapter.php
  98. +2
    -3
      src/Core/Config/JITPConfigAdapter.php
  99. +1
    -2
      src/Core/Config/PreloadConfigAdapter.php
  100. +1
    -2
      src/Core/Config/PreloadPConfigAdapter.php

+ 3
- 3
boot.php View File

@@ -29,7 +29,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
@@ -803,7 +803,7 @@ function run_update_function($x, $prefix)
function check_addons(App $a)
{
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$installed = $r;
} else {
$installed = [];
@@ -1002,7 +1002,7 @@ function feed_birthday($uid, $tz)
intval($uid)
);

if (DBM::is_result($p)) {
if (DBA::is_result($p)) {
$tmp_dob = substr($p[0]['dob'], 5);
if (intval($tmp_dob)) {
$y = DateTimeFormat::timezoneNow($tz, 'Y');


+ 43
- 44
include/api.php View File

@@ -20,7 +20,6 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@@ -235,7 +234,7 @@ function api_login(App $a)
}
}

if (!DBM::is_result($record)) {
if (!DBA::is_result($record)) {
logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');
//header('HTTP/1.0 401 Unauthorized');
@@ -501,7 +500,7 @@ function api_unique_id_to_nurl($id)
{
$r = DBA::selectFirst('contact', ['nurl'], ['id' => $id]);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
return $r["nurl"];
} else {
return false;
@@ -631,14 +630,14 @@ function api_get_user(App $a, $contact_id = null)
}

// if the contact wasn't found, fetch it from the contacts with uid = 0
if (!DBM::is_result($uinfo)) {
if (!DBA::is_result($uinfo)) {
$r = [];

if ($url != "") {
$r = q("SELECT * FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s' LIMIT 1", dbesc(normalise_link($url)));
}

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$network_name = ContactSelector::networkToName($r[0]['network'], $r[0]['url']);

// If no nick where given, extract it from the address
@@ -1184,7 +1183,7 @@ function api_statuses_update($type)
intval(requestdata('media_ids')),
api_user()
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$phototypes = Image::supportedTypes();
$ext = $phototypes[$r[0]['type']];
$_REQUEST['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']';
@@ -1280,7 +1279,7 @@ function api_status_show($type)
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);

if (DBM::is_result($lastwall)) {
if (DBA::is_result($lastwall)) {
$in_reply_to = api_in_reply_to($lastwall);

$converted = api_convert_item($lastwall);
@@ -1365,7 +1364,7 @@ function api_users_show($type)
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => false];
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);

if (DBM::is_result($lastwall)) {
if (DBA::is_result($lastwall)) {
$in_reply_to = api_in_reply_to($lastwall);

$converted = api_convert_item($lastwall);
@@ -1440,11 +1439,11 @@ function api_users_search($type)
if (x($_GET, 'q')) {
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
$r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
}

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$k = 0;
foreach ($r as $user) {
$user_info = api_get_user($a, $user["id"]);
@@ -1824,12 +1823,12 @@ function api_statuses_show($type)

// try to fetch the item for the local user - or the public item, if there is no local one
$uri_item = Item::selectFirst(['uri'], ['id' => $id]);
if (!DBM::is_result($uri_item)) {
if (!DBA::is_result($uri_item)) {
throw new BadRequestException("There is no status with this id.");
}

$item = Item::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
if (!DBM::is_result($item)) {
if (!DBA::is_result($item)) {
throw new BadRequestException("There is no status with this id.");
}

@@ -1846,7 +1845,7 @@ function api_statuses_show($type)
$statuses = Item::selectForUser(api_user(), [], $condition, $params);

/// @TODO How about copying this to above methods which don't check $r ?
if (!DBM::is_result($statuses)) {
if (!DBA::is_result($statuses)) {
throw new BadRequestException("There is no status with this id.");
}

@@ -1904,12 +1903,12 @@ function api_conversation_show($type)

// try to fetch the item for the local user - or the public item, if there is no local one
$item = Item::selectFirst(['parent-uri'], ['id' => $id]);
if (!DBM::is_result($item)) {
if (!DBA::is_result($item)) {
throw new BadRequestException("There is no status with this id.");
}

$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
if (!DBM::is_result($parent)) {
if (!DBA::is_result($parent)) {
throw new BadRequestException("There is no status with this id.");
}

@@ -1926,7 +1925,7 @@ function api_conversation_show($type)
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
$statuses = Item::selectForUser(api_user(), [], $condition, $params);

if (!DBM::is_result($statuses)) {
if (!DBA::is_result($statuses)) {
throw new BadRequestException("There is no status with id $id.");
}

@@ -1976,7 +1975,7 @@ function api_statuses_repeat($type)
$fields = ['body', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
$item = Item::selectFirst($fields, ['id' => $id, 'private' => false]);

if (DBM::is_result($item) && $item['body'] != "") {
if (DBA::is_result($item) && $item['body'] != "") {
if (strpos($item['body'], "[/share]") !== false) {
$pos = strpos($item['body'], "[share");
$post = substr($item['body'], $pos);
@@ -2226,7 +2225,7 @@ function api_favorites_create_destroy($type)

$item = Item::selectFirstForUser(api_user(), [], ['id' => $itemid, 'uid' => api_user()]);

if (!DBM::is_result($item)) {
if (!DBA::is_result($item)) {
throw new BadRequestException("Invalid item.");
}

@@ -3410,7 +3409,7 @@ function api_ff_ids($type)
WHERE `contact`.`uid` = %s AND NOT `contact`.`self`",
intval(api_user())
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
return;
}

@@ -3486,7 +3485,7 @@ function api_direct_messages_new($type)
dbesc($_POST['screen_name'])
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
// Selecting the id by priority, friendica first
api_best_nickname($r);

@@ -3590,7 +3589,7 @@ function api_direct_messages_destroy($type)
);

// error message if specified id is not in database
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
if ($verbose == "true") {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
return api_format_data("direct_messages_delete", $type, ['$result' => $answer]);
@@ -3695,7 +3694,7 @@ function api_direct_messages_box($type, $box, $verbose)
intval($start),
intval($count)
);
if ($verbose == "true" && !DBM::is_result($r)) {
if ($verbose == "true" && !DBA::is_result($r)) {
$answer = ['result' => 'error', 'message' => 'no mails available'];
return api_format_data("direct_messages_all", $type, ['$result' => $answer]);
}
@@ -3850,7 +3849,7 @@ function api_fr_photoalbum_delete($type)
intval(api_user()),
dbesc($album)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException("album not available");
}

@@ -3860,7 +3859,7 @@ function api_fr_photoalbum_delete($type)
$condition = ['uid' => local_user(), 'resource-id' => $rr['resource-id'], 'type' => 'photo'];
$photo_item = Item::selectFirstForUser(local_user(), ['id'], $condition);

if (!DBM::is_result($photo_item)) {
if (!DBA::is_result($photo_item)) {
throw new InternalServerErrorException("problem with deleting items occured");
}
Item::deleteForUser(['id' => $photo_item['id']], api_user());
@@ -3940,7 +3939,7 @@ function api_fr_photos_list($type)
'image/gif' => 'gif'
];
$data = ['photo'=>[]];
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
foreach ($r as $rr) {
$photo = [];
$photo['id'] = $rr['resource-id'];
@@ -4012,7 +4011,7 @@ function api_fr_photo_create_update($type)
dbesc($photo_id),
dbesc($album)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException("photo not available");
}
}
@@ -4135,7 +4134,7 @@ function api_fr_photo_delete($type)
intval(api_user()),
dbesc($photo_id)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException("photo not available");
}
// now we can perform on the deletion of the photo
@@ -4147,7 +4146,7 @@ function api_fr_photo_delete($type)
$condition = ['uid' => local_user(), 'resource-id' => $photo_id, 'type' => 'photo'];
$photo_item = Item::selectFirstForUser(local_user(), ['id'], $condition);

if (!DBM::is_result($photo_item)) {
if (!DBA::is_result($photo_item)) {
throw new InternalServerErrorException("problem with deleting items occured");
}
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
@@ -4214,7 +4213,7 @@ function api_account_update_profile_image($type)
if ($profile_id != 0) {
$profile = DBA::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
// error message if specified profile id is not in database
if (!DBM::is_result($profile)) {
if (!DBA::is_result($profile)) {
throw new BadRequestException("profile_id not available");
}
$is_default_profile = $profile['is-default'];
@@ -4346,7 +4345,7 @@ function check_acl_input($acl_string)
intval($cid),
intval(api_user())
);
$contact_not_found |= !DBM::is_result($contact);
$contact_not_found |= !DBA::is_result($contact);
}
return $contact_not_found;
}
@@ -4608,7 +4607,7 @@ function prepare_photo_data($type, $scale, $photo_id)
];

// prepare output data for photo
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$data = ['photo' => $r[0]];
$data['photo']['id'] = $data['photo']['resource-id'];
if ($scale !== false) {
@@ -4703,7 +4702,7 @@ function api_friendica_remoteauth()

$contact = DBA::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);

if (!DBM::is_result($contact) || ($contact['network'] !== NETWORK_DFRN)) {
if (!DBA::is_result($contact) || ($contact['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");
}

@@ -4854,7 +4853,7 @@ function api_get_nick($profile)
dbesc(normalise_link($profile))
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$nick = $r[0]["nick"];
}

@@ -4864,7 +4863,7 @@ function api_get_nick($profile)
dbesc(normalise_link($profile))
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$nick = $r[0]["nick"];
}
}
@@ -4939,7 +4938,7 @@ function api_in_reply_to($item)

if (($item['thr-parent'] != $item['uri']) && (intval($item['parent']) != intval($item['id']))) {
$parent = Item::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
if (DBM::is_result($parent)) {
if (DBA::is_result($parent)) {
$in_reply_to['status_id'] = intval($parent['id']);
} else {
$in_reply_to['status_id'] = intval($item['parent']);
@@ -4950,7 +4949,7 @@ function api_in_reply_to($item)
$fields = ['author-nick', 'author-name', 'author-id', 'author-link'];
$parent = Item::selectFirst($fields, ['id' => $in_reply_to['status_id']]);

if (DBM::is_result($parent)) {
if (DBA::is_result($parent)) {
if ($parent['author-nick'] == "") {
$parent['author-nick'] = api_get_nick($parent['author-link']);
}
@@ -5127,7 +5126,7 @@ function api_friendica_group_show($type)
intval($gid)
);
// error message if specified gid is not in database
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException("gid not available");
}
} else {
@@ -5197,7 +5196,7 @@ function api_friendica_group_delete($type)
intval($gid)
);
// error message if specified gid is not in database
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException('gid not available');
}

@@ -5209,7 +5208,7 @@ function api_friendica_group_delete($type)
dbesc($name)
);
// error message if specified gid is not in database
if (!DBM::is_result($rname)) {
if (!DBA::is_result($rname)) {
throw new BadRequestException('wrong group name');
}

@@ -5294,7 +5293,7 @@ function group_create($name, $uid, $users = [])
dbesc($name)
);
// error message if specified group name already exists
if (DBM::is_result($rname)) {
if (DBA::is_result($rname)) {
throw new BadRequestException('group name already exists');
}

@@ -5305,7 +5304,7 @@ function group_create($name, $uid, $users = [])
dbesc($name)
);
// error message if specified group name already exists
if (DBM::is_result($rname)) {
if (DBA::is_result($rname)) {
$reactivate_group = true;
}

@@ -5636,7 +5635,7 @@ function api_friendica_notification_seen($type)
if ($note['otype']=='item') {
// would be really better with an ItemsManager and $im->getByID() :-P
$item = Item::selectFirstForUser(api_user(), [], ['id' => $note['iid'], 'uid' => api_user()]);
if (DBM::is_result($$item)) {
if (DBA::is_result($$item)) {
// we found the item, return it to the user
$ret = api_format_items([$item], $user_info, false, $type);
$data = ['status' => $ret];
@@ -5735,7 +5734,7 @@ function api_friendica_direct_messages_search($type, $box = "")
$profile_url = $user_info["url"];

// message if nothing was found
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
$success = ['success' => false, 'search_results' => 'problem with query'];
} elseif (count($r) == 0) {
$success = ['success' => false, 'search_results' => 'nothing found'];
@@ -5793,7 +5792,7 @@ function api_friendica_profile_show($type)
);

// error message if specified gid is not in database
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
throw new BadRequestException("profile_id not available");
}
} else {


+ 4
- 5
include/conversation.php View File

@@ -13,7 +13,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Profile;
@@ -136,7 +135,7 @@ function localize_item(&$item)

$fields = ['author-link', 'author-name', 'verb', 'object-type', 'resource-id', 'body', 'plink'];
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
if (!DBM::is_result($obj)) {
if (!DBA::is_result($obj)) {
return;
}

@@ -267,7 +266,7 @@ function localize_item(&$item)
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
'verb', 'object-type', 'resource-id', 'body', 'plink'];
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
if (!DBM::is_result($obj)) {
if (!DBA::is_result($obj)) {
return;
}

@@ -322,7 +321,7 @@ function localize_item(&$item)
if (strlen($obj->id)) {
$fields = ['author-link', 'author-name', 'plink'];
$target = Item::selectFirst($fields, ['uri' => $obj->id, 'uid' => $item['uid']]);
if (DBM::is_result($target) && $target['plink']) {
if (DBA::is_result($target) && $target['plink']) {
$Bname = $target['author-name'];
$Blink = $target['author-link'];
$A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
@@ -830,7 +829,7 @@ function item_photo_menu($item) {
$rel = 0;
$condition = ['uid' => local_user(), 'nurl' => normalise_link($item['author-link'])];
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$cid = $contact['id'];
$network = $contact['network'];
$rel = $contact['rel'];


+ 8
- 9
include/enotify.php View File

@@ -9,7 +9,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
@@ -54,7 +53,7 @@ function notification($params)
['uid' => $params['uid']]);

// There is no need to create notifications for forum accounts
if (!DBM::is_result($user) || in_array($user["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
if (!DBA::is_result($user) || in_array($user["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
return;
}
}
@@ -108,7 +107,7 @@ function notification($params)

if ($params['type'] == NOTIFY_COMMENT) {
$thread = DBA::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($thread) && $thread["ignored"]) {
if (DBA::is_result($thread) && $thread["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
}
@@ -156,7 +155,7 @@ function notification($params)
}

// "your post"
if (DBM::is_result($item) && $item['owner-id'] == $item['author-id'] && $item['wall']) {
if (DBA::is_result($item) && $item['owner-id'] == $item['author-id'] && $item['wall']) {
$dest_str = L10n::t('%1$s commented on [url=%2$s]your %3$s[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$itemlink,
@@ -438,7 +437,7 @@ function notification($params)
$hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash));
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$dups = true;
}
} while ($dups == true);
@@ -690,12 +689,12 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {

$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
$user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
return false;
}

$owner = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
if (!DBA::is_result($owner)) {
return false;
}

@@ -746,7 +745,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
'guid', 'parent-uri', 'uri', 'contact-id', 'network'];
$condition = ['id' => $itemid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$item = Item::selectFirst($fields, $condition);
if (!DBM::is_result($item) || in_array($item['author-id'], $contacts)) {
if (!DBA::is_result($item) || in_array($item['author-id'], $contacts)) {
return;
}

@@ -773,7 +772,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));

if (DBM::is_result($tags)) {
if (DBA::is_result($tags)) {
foreach ($tags AS $tag) {
$condition = ['nurl' => normalise_link($tag["url"]), 'uid' => $uid, 'notify_new_posts' => true];
$r = DBA::exists('contact', $condition);


+ 4
- 5
include/items.php View File

@@ -10,7 +10,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Feed;
@@ -266,7 +265,7 @@ function consume_feed($xml, $importer, $contact, &$hub, $datedir = 0, $pass = 0)
WHERE `contact`.`id` = %d AND `user`.`uid` = %d",
dbesc($contact["id"]), dbesc($importer["uid"])
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
logger("Now import the DFRN feed");
DFRN::import($xml, $r[0], true);
return;
@@ -290,7 +289,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
* through the direct Diaspora protocol. If we try and use
* the feed, we'll get duplicates. So don't.
*/
if ((!DBM::is_result($r)) || $contact['network'] === NETWORK_DIASPORA) {
if ((!DBA::is_result($r)) || $contact['network'] === NETWORK_DIASPORA) {
return;
}

@@ -341,7 +340,7 @@ function drop_item($id) {
$fields = ['id', 'uid', 'contact-id', 'deleted'];
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);

if (!DBM::is_result($item)) {
if (!DBA::is_result($item)) {
notice(L10n::t('Item not found.') . EOL);
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
}
@@ -462,7 +461,7 @@ function posted_date_widget($url, $uid, $wall) {

$ret = list_post_dates($uid, $wall);

if (!DBM::is_result($ret)) {
if (!DBA::is_result($ret)) {
return $o;
}



+ 9
- 10
include/security.php View File

@@ -9,7 +9,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Util\DateTimeFormat;

@@ -101,7 +100,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive

if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
$user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
if (DBM::is_result($user)) {
if (DBA::is_result($user)) {
$master_record = $user;
}
}
@@ -115,7 +114,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
// Then add all the children
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$a->identities = array_merge($a->identities, DBA::toArray($r));
}
} else {
@@ -125,14 +124,14 @@ function authenticate_success($user_record, $login_initial = false, $interactive
// First entry is our parent
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$a->identities = DBA::toArray($r);
}

// Then add all siblings
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$a->identities = array_merge($a->identities, DBA::toArray($r));
}
}
@@ -143,7 +142,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?",
$master_record['uid']
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$a->identities = array_merge($a->identities, DBA::toArray($r));
}

@@ -155,7 +154,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
}

$contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$a->contact = $contact;
$a->cid = $contact['id'];
$_SESSION['cid'] = $a->cid;
@@ -247,7 +246,7 @@ function can_write_wall($owner)
intval(PAGE_COMMUNITY)
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$verified = 2;
return true;
} else {
@@ -302,7 +301,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null)
intval($remote_user),
intval($owner_id)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$remote_verified = true;
$groups = Group::getIdsByContactId($remote_user);
}
@@ -365,7 +364,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul
intval($remote_user),
intval($owner_id)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$remote_verified = true;
$groups = Group::getIdsByContactId($remote_user);
}


+ 9
- 10
include/text.php View File

@@ -13,11 +13,10 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Render\FriendicaSmarty;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
@@ -760,7 +759,7 @@ function contact_block() {
dbesc(NETWORK_OSTATUS),
dbesc(NETWORK_DIASPORA)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$total = intval($r[0]['total']);
}
if (!$total) {
@@ -779,7 +778,7 @@ function contact_block() {
dbesc(NETWORK_DIASPORA),
intval($shown)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$contacts = [];
foreach ($r AS $contact) {
$contacts[] = $contact["id"];
@@ -787,7 +786,7 @@ function contact_block() {
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
dbesc(implode(",", $contacts)));

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$contacts = L10n::tt('%d Contact', '%d Contacts', $total);
$micropro = [];
foreach ($r as $rr) {
@@ -1470,7 +1469,7 @@ function generate_user_guid() {
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
if (!DBM::is_result($x)) {
if (!DBA::is_result($x)) {
$found = false;
}
} while ($found == true);
@@ -1759,7 +1758,7 @@ function file_tag_update_pconfig($uid, $file_old, $file_new, $type = 'file') {
intval($termtype),
intval($uid));

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
unset($deleted_tags[$key]);
} else {
$filetags_updated = str_replace($lbracket . file_tag_encode($tag) . $rbracket,'',$filetags_updated);
@@ -1783,7 +1782,7 @@ function file_tag_save_file($uid, $item_id, $file)
}

$item = Item::selectFirst(['file'], ['id' => $item_id, 'uid' => $uid]);
if (DBM::is_result($item)) {
if (DBA::is_result($item)) {
if (!stristr($item['file'],'[' . file_tag_encode($file) . ']')) {
$fields = ['file' => $item['file'] . '[' . file_tag_encode($file) . ']'];
Item::update($fields, ['id' => $item_id]);
@@ -1812,7 +1811,7 @@ function file_tag_unsave_file($uid, $item_id, $file, $cat = false)
}

$item = Item::selectFirst(['file'], ['id' => $item_id, 'uid' => $uid]);
if (!DBM::is_result($item)) {
if (!DBA::is_result($item)) {
return false;
}

@@ -1825,7 +1824,7 @@ function file_tag_unsave_file($uid, $item_id, $file, $cat = false)
intval($termtype),
intval($uid)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
$saved = PConfig::get($uid, 'system', 'filetags');
PConfig::set($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
}


+ 1
- 2
index.php View File

@@ -18,7 +18,6 @@ use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Module\Login;

@@ -96,7 +95,7 @@ if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we haven't loaded user data yet, but we need user language
$user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
if (DBM::is_result($user)) {
if (DBA::is_result($user)) {
$_SESSION['language'] = $user['language'];
}
}


+ 2
- 3
mod/acl.php View File

@@ -7,7 +7,6 @@ use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;

@@ -210,7 +209,7 @@ function acl_content(App $a)
exit;
}

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$forums = [];
foreach ($r as $g) {
$entry = [
@@ -243,7 +242,7 @@ function acl_content(App $a)
if ($conv_id) {
// In multi threaded posts the conv_id is not the parent of the whole thread
$parent_item = Item::selectFirst(['parent'], ['id' => $conv_id]);
if (DBM::is_result($parent_item)) {
if (DBA::is_result($parent_item)) {
$conv_id = $parent_item['parent'];
}



+ 4
- 5
mod/admin.php View File

@@ -15,7 +15,6 @@ use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
use Friendica\Model\Item;
@@ -819,7 +818,7 @@ function admin_page_summary(App $a)
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(DBA::databaseName()));
$showwarning = false;
$warningtext = [];
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$showwarning = true;
$warningtext[] = L10n::t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php bin/console.php dbstructure toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
}
@@ -961,7 +960,7 @@ function admin_page_site_post(App $a)

$r = q("UPDATE %s SET %s;", $table_name, $upds);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
notice("Failed updating '$table_name': " . DBA::errorMessage());
goaway('admin/site');
}
@@ -1581,7 +1580,7 @@ function admin_page_dbsync(App $a)
$failed = [];
$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
foreach ($r as $rr) {
$upd = intval(substr($rr['k'], 7));
if ($upd < 1139 || $rr['v'] === 'success') {
@@ -1731,7 +1730,7 @@ function admin_page_users(App $a)
if ($a->argc > 2) {
$uid = $a->argv[3];
$user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');
return ''; // NOTREACHED


+ 2
- 3
mod/allfriends.php View File

@@ -8,7 +8,6 @@ use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
@@ -37,7 +36,7 @@ function allfriends_content(App $a)

$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);

if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
return;
}

@@ -49,7 +48,7 @@ function allfriends_content(App $a)
$a->set_pager_total($total);

$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
$o .= L10n::t('No friends to display.');
return $o;
}


+ 2
- 2
mod/api.php View File

@@ -5,7 +5,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Module\Login;

require_once 'include/api.php';
@@ -22,7 +22,7 @@ function oauth_get_client($request)
WHERE `clients`.`client_id`=`tokens`.`client_id`
AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'", dbesc($token));

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
return null;
}



+ 2
- 3
mod/attach.php View File

@@ -6,7 +6,6 @@
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Database\DBM;

require_once 'include/dba.php';
require_once 'include/security.php';
@@ -23,7 +22,7 @@ function attach_init(App $a)
// Check for existence, which will also provide us the owner uid

$r = DBA::selectFirst('attach', [], ['id' => $item_id]);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
notice(L10n::t('Item was not found.'). EOL);
return;
}
@@ -36,7 +35,7 @@ function attach_init(App $a)
dbesc($item_id)
);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
notice(L10n::t('Permission denied.') . EOL);
return;
}


+ 3
- 4
mod/cal.php View File

@@ -14,7 +14,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Group;
@@ -38,7 +37,7 @@ function cal_init(App $a)
if ($a->argc > 1) {
$nick = $a->argv[1];
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
return;
}

@@ -132,7 +131,7 @@ function cal_content(App $a)
intval($contact_id),
intval($a->profile['profile_uid'])
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$remote_contact = true;
}
}
@@ -230,7 +229,7 @@ function cal_content(App $a)

$links = [];

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$r = Event::sortByDate($r);
foreach ($r as $rr) {
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');


+ 6
- 7
mod/common.php View File

@@ -7,7 +7,6 @@ use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
@@ -40,14 +39,14 @@ function common_content(App $a)
if ($cmd === 'loc' && $cid) {
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);

if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
}
} else {
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);

if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
'$name' => htmlentities($contact['name']),
'$photo' => $contact['photo'],
@@ -61,17 +60,17 @@ function common_content(App $a)
}
}

if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
return;
}

if (!$cid && Profile::getMyURL()) {
$contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$cid = $contact['id'];
} else {
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
if (DBA::is_result($gcontact)) {
$zcid = $gcontact['id'];
}
}
@@ -100,7 +99,7 @@ function common_content(App $a)
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
}

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
return $o;
}



+ 1
- 2
mod/community.php View File

@@ -10,7 +10,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Database\DBM;

function community_init(App $a)
{
@@ -138,7 +137,7 @@ function community_content(App $a, $update = 0)

$r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
info(L10n::t('No results.') . EOL);
return $o;
}


+ 3
- 3
mod/contactgroup.php View File

@@ -1,7 +1,7 @@
<?php

use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;

@@ -17,7 +17,7 @@ function contactgroup_content(App $a)
intval($a->argv[2]),
intval(local_user())
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$change = intval($a->argv[2]);
}
}
@@ -27,7 +27,7 @@ function contactgroup_content(App $a)
intval($a->argv[1]),
intval(local_user())
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
killme();
}



+ 13
- 14
mod/contacts.php View File

@@ -13,7 +13,6 @@ use Friendica\Core\L10n;
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;
@@ -45,7 +44,7 @@ function contacts_init(App $a)
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}

if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
if ($contact['self']) {
if (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts")) {
goaway('profile/' . $contact['nick']);
@@ -225,14 +224,14 @@ function contacts_post(App $a)
intval($contact_id),
intval(local_user())
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
info(L10n::t('Contact updated.') . EOL);
} else {
notice(L10n::t('Failed to update contact record.') . EOL);
}

$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$a->data['contact'] = $contact;
}

@@ -244,7 +243,7 @@ function contacts_post(App $a)
function _contact_update($contact_id)
{
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
return;
}

@@ -265,7 +264,7 @@ function _contact_update($contact_id)
function _contact_update_profile($contact_id)
{
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
return;
}

@@ -336,7 +335,7 @@ function _contact_block($contact_id, $orig_record)
intval($contact_id),
intval(local_user())
);
return DBM::is_result($r);
return DBA::is_result($r);
}

function _contact_ignore($contact_id, $orig_record)
@@ -347,7 +346,7 @@ function _contact_ignore($contact_id, $orig_record)
intval($contact_id),
intval(local_user())
);
return DBM::is_result($r);
return DBA::is_result($r);
}

function _contact_archive($contact_id, $orig_record)
@@ -358,7 +357,7 @@ function _contact_archive($contact_id, $orig_record)
intval($contact_id),
intval(local_user())
);
return DBM::is_result($r);
return DBA::is_result($r);
}

function _contact_drop($orig_record)
@@ -369,7 +368,7 @@ function _contact_drop($orig_record)
WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
intval($a->user['uid'])
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
return;
}

@@ -397,7 +396,7 @@ function contacts_content(App $a)
$cmd = $a->argv[2];

$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
if (!DBM::is_result($orig_record)) {
if (!DBA::is_result($orig_record)) {
notice(L10n::t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@@ -788,7 +787,7 @@ function contacts_content(App $a)
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
intval($_SESSION['uid'])
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$a->set_pager_total($r[0]['total']);
$total = $r[0]['total'];
}
@@ -802,7 +801,7 @@ function contacts_content(App $a)
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
foreach ($r as $rr) {
$contacts[] = _contact_detail_for_template($rr);
}
@@ -911,7 +910,7 @@ function contact_posts($a, $contact_id)
$o = contacts_tab($a, $contact_id, 1);

$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
$o .= Contact::getPostsFromUrl($contact["url"]);


+ 3
- 4
mod/crepair.php View File

@@ -7,7 +7,6 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;

@@ -28,7 +27,7 @@ function crepair_init(App $a)
$a->page['aside'] = '';
}

if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$a->data['contact'] = $contact;
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
}
@@ -47,7 +46,7 @@ function crepair_post(App $a)
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}

if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
return;
}

@@ -108,7 +107,7 @@ function crepair_content(App $a)
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}

if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
notice(L10n::t('Contact not found.') . EOL);
return;
}


+ 6
- 7
mod/delegate.php View File

@@ -7,7 +7,6 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;

require_once 'mod/settings.php';
@@ -35,7 +34,7 @@ function delegate_post(App $a)

if ($parent_uid != 0) {
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
notice(L10n::t('Parent user not found.') . EOL);
return;
}
@@ -66,7 +65,7 @@ function delegate_content(App $a)
$user_id = $a->argv[2];

$user = DBA::selectFirst('user', ['nickname'], ['uid' => $user_id]);
if (DBM::is_result($user)) {
if (DBA::is_result($user)) {
$condition = [
'uid' => local_user(),
'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname'])
@@ -93,7 +92,7 @@ function delegate_content(App $a)
$r = q("SELECT * FROM `user` WHERE `uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = %d)",
intval(local_user())
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$delegates = $r;
}

@@ -115,7 +114,7 @@ function delegate_content(App $a)
intval(local_user()),
dbesc(NETWORK_DFRN)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$nicknames = [];
foreach ($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
@@ -125,7 +124,7 @@ function delegate_content(App $a)

// get user records for all potential page delegates who are not already delegates or managers
$r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ($nicks)");
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
foreach ($r as $rr) {
if (!in_array($rr['uid'], $uids)) {
$potentials[] = $rr;
@@ -140,7 +139,7 @@ function delegate_content(App $a)

$parent_user = null;

if (DBM::is_result($user)) {
if (DBA::is_result($user)) {
if (!DBA::exists('user', ['parent-uid' => local_user()])) {
$parent_uid = $user['parent-uid'];
$parents = [0 => L10n::t('No parent user')];


+ 12
- 13
mod/dfrn_confirm.php View File

@@ -22,7 +22,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\User;
@@ -68,7 +67,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}

$user = DBA::selectFirst('user', [], ['uid' => $uid]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
notice(L10n::t('Profile not found.') . EOL);
return;
}
@@ -122,7 +121,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
intval($cid),
intval($uid)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
logger('Contact not found in DB.');
notice(L10n::t('Contact not found.') . EOL);
notice(L10n::t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL);
@@ -281,7 +280,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)

if (($status == 0) && $intro_id) {
$intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
if (DBM::is_result($intro)) {
if (DBA::is_result($intro)) {
DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
}

@@ -386,14 +385,14 @@ function dfrn_confirm_post(App $a, $handsfree = null)
);
}

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
notice(L10n::t('Unable to set contact photo.') . EOL);
}

// reload contact info
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
if (DBM::is_result($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
if (DBA::is_result($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
$ret = Diaspora::sendShare($user, $contact);
logger('share returns: ' . $ret);
}
@@ -444,7 +443,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)

// Find our user's account
$user = DBA::selectFirst('user', [], ['nickname' => $node]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
$message = L10n::t('No user record found for \'%s\' ', $node);
System::xmlExit(3, $message); // failure
// NOTREACHED
@@ -472,7 +471,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}

$contact = DBA::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
if (strstr($decrypted_source_url, 'http:')) {
$newurl = str_replace('http:', 'https:', $decrypted_source_url);
} else {
@@ -480,7 +479,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}

$contact = DBA::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
if (!DBA::is_result($contact)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = L10n::t('Contact record was not found for you on our site.');
System::xmlExit(3, $message);
@@ -522,7 +521,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
dbesc($dfrn_pubkey),
intval($dfrn_record)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
$message = L10n::t('Unable to set your contact credentials on our system.');
System::xmlExit(3, $message);
}
@@ -538,7 +537,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)

// We're good but now we have to scrape the profile photo and send notifications.
$contact = DBA::selectFirst('contact', ['photo'], ['id' => $dfrn_record]);
if (DBM::is_result($contact)) {
if (DBA::is_result($contact)) {
$photo = $contact['photo'];
} else {
$photo = System::baseUrl() . '/images/person-175.jpg';
@@ -577,7 +576,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
dbesc(NETWORK_DFRN),
intval($dfrn_record)
);
if (!DBM::is_result($r)) { // indicates schema is messed up or total db failure
if (!DBA::is_result($r)) { // indicates schema is messed up or total db failure
$message = L10n::t('Unable to update your contact profile details on our system');
System::xmlExit(3, $message);
}
@@ -595,7 +594,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
LIMIT 1",
intval($dfrn_record)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$combined = $r[0];

if ($combined['notify-flags'] & NOTIFY_CONFIRM) {


+ 5
- 6
mod/dfrn_notify.php View File

@@ -10,7 +10,6 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
@@ -28,7 +27,7 @@ function dfrn_notify_post(App $a) {
$nick = defaults($a->argv, 1, '');

$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($user)) {
if (!DBA::is_result($user)) {
System::httpExit(500);
}
dfrn_dispatch_private($user, $postdata);
@@ -108,7 +107,7 @@ function dfrn_notify_post(App $a) {
dbesc($a->argv[1])
);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
logger('contact not found for dfrn_id ' . $dfrn_id);
System::xmlExit(3, 'Contact not found');
//NOTREACHED
@@ -221,7 +220,7 @@ function dfrn_dispatch_public($postdata)
$importer['importer_uid'] = 0;

// This should never fail
if (!DBM::is_result($importer)) {
if (!DBA::is_result($importer)) {
logger('Contact not found for address ' . $msg['author']);
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
}
@@ -258,7 +257,7 @@ function dfrn_dispatch_private($user, $postdata)
$cid);

// This should never fail
if (!DBM::is_result($importer)) {
if (!DBA::is_result($importer)) {
logger('Contact not found for address ' . $msg['author']);
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
}
@@ -335,7 +334,7 @@ function dfrn_notify_content(App $a) {
dbesc($a->argv[1])
);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
logger('No user data found for ' . $a->argv[1] . ' - SQL: ' . $sql_extra);
killme();
}


+ 11
- 12
mod/dfrn_poll.php View File

@@ -9,7 +9,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
@@ -101,7 +100,7 @@ function dfrn_poll_init(App $a)
dbesc($a->argv[1])
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');

logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
@@ -147,7 +146,7 @@ function dfrn_poll_init(App $a)
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
System::xmlExit(3, 'No ticket');
// NOTREACHED
}
@@ -160,7 +159,7 @@ function dfrn_poll_init(App $a)
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($r[0]['cid'])
);
if (!DBM::is_result($c)) {
if (!DBA::is_result($c)) {
System::xmlExit(3, 'No profile');
}

@@ -211,7 +210,7 @@ function dfrn_poll_init(App $a)
DBA::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id));
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
System::xmlExit(1);
return; // NOTREACHED
}
@@ -239,7 +238,7 @@ function dfrn_poll_post(App $a)
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
System::xmlExit(3, 'No ticket');
// NOTREACHED
}
@@ -252,7 +251,7 @@ function dfrn_poll_post(App $a)
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($r[0]['cid'])
);
if (!DBM::is_result($c)) {
if (!DBA::is_result($c)) {
System::xmlExit(3, 'No profile');
}

@@ -301,7 +300,7 @@ function dfrn_poll_post(App $a)
dbesc($challenge)
);

if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
killme();
}

@@ -330,7 +329,7 @@ function dfrn_poll_post(App $a)
}

$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
if (!DBM::is_result($r)) {
if (!DBA::is_result($r)) {
killme();
}

@@ -346,7 +345,7 @@ function dfrn_poll_post(App $a)
$reputation = 0;
$text = '';

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$reputation = $r[0]['rating'];
$text = $r[0]['reason'];

@@ -458,7 +457,7 @@ function dfrn_poll_content(App $a)
AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
dbesc($nickname)
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$challenge = '';
$encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000, 9999);
@@ -499,7 +498,7 @@ function dfrn_poll_content(App $a)
]);
}

$profile = ((DBM::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
$profile = ((DBA::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);

switch ($destination_url) {
case 'profile':


+ 10
- 11
mod/dfrn_request.php View File

@@ -17,7 +17,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
@@ -88,7 +87,7 @@ function dfrn_request_post(App $a)
dbesc(normalise_link($dfrn_url))
);

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
if (strlen($r[0]['dfrn-id'])) {
// We don't need to be here. It has already happened.
notice(L10n::t("This introduction has already been accepted.") . EOL);
@@ -130,7 +129,7 @@ function dfrn_request_post(App $a)
$photo = $parms["photo"];

// Escape the entire array
DBM::esc_array($parms);
DBA::esc_array($parms);

// Create a contact record on our site for the other person
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `addr`, `name`, `nick`, `photo`, `site-pubkey`,
@@ -167,7 +166,7 @@ function dfrn_request_post(App $a)
dbesc($dfrn_url),
$parms['key'] // this was already escaped
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);

if (isset($photo)) {
@@ -243,7 +242,7 @@ function dfrn_request_post(App $a)
dbesc(DateTimeFormat::utc('now - 24 hours')),
intval($uid)
);
if (DBM::is_result($r) && count($r) > $maxreq) {
if (DBA::is_result($r) && count($r) > $maxreq) {
notice(L10n::t('%s has received too many connection requests today.', $a->profile['name']) . EOL);
notice(L10n::t('Spam protection measures have been invoked.') . EOL);
notice(L10n::t('Friends are advised to please try again in 24 hours.') . EOL);
@@ -259,7 +258,7 @@ function dfrn_request_post(App $a)
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE "
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
foreach ($r as $rr) {
if (!$rr['rel']) {
DBA::delete('contact', ['id' => $rr['cid'], 'self' => false]);
@@ -306,7 +305,7 @@ function dfrn_request_post(App $a)
dbesc($url)
);

if (DBM::is_result($ret)) {
if (DBA::is_result($ret)) {
if (strlen($ret[0]['issued-id'])) {
notice(L10n::t('You have already introduced yourself here.') . EOL);
return;
@@ -372,7 +371,7 @@ function dfrn_request_post(App $a)
$parms['issued-id'] = $issued_id;
$photo = $parms["photo"];

DBM::esc_array($parms);
DBA::esc_array($parms);
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
@@ -404,7 +403,7 @@ function dfrn_request_post(App $a)
$parms['url'],
$parms['issued-id']
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
$contact_record = $r[0];
Contact::updateAvatar($photo, $uid, $contact_record["id"], true);
}
@@ -538,7 +537,7 @@ function dfrn_request_content(App $a)
dbesc($_GET['confirm_key'])
);

if (DBM::is_result($intro)) {
if (DBA::is_result($intro)) {
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`id` = %d LIMIT 1",
intval($intro[0]['contact-id'])
@@ -546,7 +545,7 @@ function dfrn_request_content(App $a)

$auto_confirm = false;

if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
if ($r[0]['page-flags'] != PAGE_NORMAL && $r[0]['page-flags'] != PAGE_PRVGROUP) {
$auto_confirm = true;
}


+ 2
- 3
mod/directory.php View File

@@ -10,7 +10,6 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;

@@ -86,7 +85,7 @@ function directory_content(App $a)
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
if (DBM::is_result($cnt)) {
if (DBA::is_result($cnt)) {
$a->set_pager_total($cnt['total']);
}

@@ -101,7 +100,7 @@ function directory_content(App $a)
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
$sql_extra $order LIMIT $limit"
);
if (DBM::is_result($r)) {
if (DBA::is_result($r)) {
if (in_array('small', $a->argv)) {
$photo = 'thumb';
} else {


+ 2
- 3
mod/dirfind.php View File