mirror of
https://github.com/friendica/friendica
synced 2024-11-08 13:52:23 +01:00
More usage of dbm::is_result($r) instead of count($r):
- count() returns very different results and never a boolean (not even false on error condition). - therefore you should NOT use it in boolean expressions. This still *can* be done in PHP because of its lazyness. But it is discouraged if it comes to more clean code. Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
parent
293436e5fd
commit
6a8a36f12d
|
@ -64,7 +64,7 @@ function contact_remove($id) {
|
|||
$r = q("select uid from contact where id = %d limit 1",
|
||||
intval($id)
|
||||
);
|
||||
if((! count($r)) || (! intval($r[0]['uid'])))
|
||||
if((! dbm::is_result($r)) || (! intval($r[0]['uid'])))
|
||||
return;
|
||||
|
||||
$archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
|
||||
|
@ -249,7 +249,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
FROM `gcontact` WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($url)));
|
||||
|
||||
if ($r) {
|
||||
if (dbm::is_result($r)) {
|
||||
// If there is more than one entry we filter out the connector networks
|
||||
if (count($r) > 1) {
|
||||
foreach ($r AS $id => $result) {
|
||||
|
@ -435,7 +435,7 @@ function random_profile() {
|
|||
ORDER BY rand() LIMIT 1",
|
||||
dbesc(NETWORK_DFRN));
|
||||
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return dirname($r[0]['url']);
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class Config {
|
|||
$a = get_app();
|
||||
|
||||
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$k = $rr['k'];
|
||||
if ($family === 'config') {
|
||||
|
|
|
@ -33,7 +33,7 @@ class PConfig {
|
|||
dbesc($family),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$k = $rr['k'];
|
||||
$a->config[$uid][$family][$k] = $rr['v'];
|
||||
|
|
|
@ -1084,7 +1084,7 @@ class Probe {
|
|||
|
||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
|
||||
|
||||
if(count($x) && count($r)) {
|
||||
if(dbm::is_result($x) && dbm::is_result($r)) {
|
||||
$mailbox = construct_mailbox_name($r[0]);
|
||||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);
|
||||
|
|
|
@ -33,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
|
||||
call_hooks($a->module . '_pre_' . $selname, $arr);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = " selected=\"selected\" ";
|
||||
|
@ -144,7 +144,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
|
||||
call_hooks($a->module . '_pre_' . $selname, $arr);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = " selected=\"selected\" ";
|
||||
|
@ -220,7 +220,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
|
||||
$receiverlist = array();
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = " selected=\"selected\" ";
|
||||
|
@ -314,7 +314,7 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
$r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$mail_enabled = true;
|
||||
if(intval($r[0]['pubmail']))
|
||||
$pubmail_enabled = true;
|
||||
|
@ -577,7 +577,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
$r = array();
|
||||
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $g){
|
||||
$contacts[] = array(
|
||||
"type" => "c",
|
||||
|
@ -612,7 +612,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
dbesc($search),
|
||||
implode("','", $known_contacts)
|
||||
);
|
||||
if (is_array($r) && count($r)){
|
||||
if (dbm::is_result($r)){
|
||||
foreach($r as $row) {
|
||||
// nickname..
|
||||
$up = parse_url($row['author-link']);
|
||||
|
|
|
@ -208,7 +208,7 @@
|
|||
dbesc(trim($user)),
|
||||
dbesc($encrypted)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$record = $r[0];
|
||||
}
|
||||
|
||||
|
@ -1326,10 +1326,10 @@
|
|||
|
||||
if (isset($_GET["q"])) {
|
||||
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
|
||||
if (!count($r))
|
||||
if (!dbm::is_result($r))
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
|
||||
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$k = 0;
|
||||
foreach ($r AS $user) {
|
||||
$user_info = api_get_user($a, $user["id"], "json");
|
||||
|
@ -3174,7 +3174,7 @@
|
|||
intval(api_user())
|
||||
);
|
||||
|
||||
if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
|
||||
if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
|
||||
throw new BadRequestException("Unknown contact");
|
||||
|
||||
$cid = $r[0]['id'];
|
||||
|
@ -3526,7 +3526,7 @@
|
|||
intval($uid),
|
||||
intval($gid));
|
||||
// error message if specified gid is not in database
|
||||
if (count($r) == 0)
|
||||
if (!dbm::is_result($r))
|
||||
throw new BadRequestException("gid not available");
|
||||
}
|
||||
else
|
||||
|
@ -3581,7 +3581,7 @@
|
|||
intval($uid),
|
||||
intval($gid));
|
||||
// error message if specified gid is not in database
|
||||
if (count($r) == 0)
|
||||
if (!dbm::is_result($r))
|
||||
throw new BadRequestException('gid not available');
|
||||
|
||||
// get data of the specified group id and group name
|
||||
|
@ -3919,7 +3919,9 @@
|
|||
|
||||
$profile_url = $user_info["url"];
|
||||
// message if nothing was found
|
||||
if (count($r) == 0)
|
||||
if (!dbm::is_result($r))
|
||||
$success = array('success' => false, 'search_results' => 'problem with query');
|
||||
else if (count($r) == 0)
|
||||
$success = array('success' => false, 'search_results' => 'nothing found');
|
||||
else {
|
||||
$ret = Array();
|
||||
|
@ -3966,7 +3968,7 @@
|
|||
intval(api_user()),
|
||||
intval($profileid));
|
||||
// error message if specified gid is not in database
|
||||
if (count($r) == 0)
|
||||
if (!dbm::is_result($r))
|
||||
throw new BadRequestException("profile_id not available");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -50,7 +50,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
|||
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($_SESSION['visitor_id'])
|
||||
);
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$a->contact = $r[0];
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
|||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
if (!count($r)) {
|
||||
if (!dbm::is_result($r)) {
|
||||
nuke_session();
|
||||
goaway(z_root());
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
|||
dbesc(trim($_POST['username'])),
|
||||
dbesc($encrypted)
|
||||
);
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$record = $r[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ function contact_profile_assign($current,$foreign_net) {
|
|||
$r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
|
||||
intval($_SESSION['uid']));
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
|
||||
|
|
|
@ -93,7 +93,7 @@ function networks_widget($baseurl,$selected = '') {
|
|||
);
|
||||
|
||||
$nets = array();
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
require_once('include/contact_selectors.php');
|
||||
foreach($r as $rr) {
|
||||
if($rr['network'])
|
||||
|
@ -204,13 +204,13 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$cid = $r[0]['id'];
|
||||
else {
|
||||
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$zcid = $r[0]['id'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ function localize_item(&$item){
|
|||
$r = q("SELECT * from `item`,`contact` WHERE
|
||||
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
|
||||
dbesc($item['parent-uri']));
|
||||
if(count($r)==0) return;
|
||||
if(!dbm::is_result($r)) return;
|
||||
$obj=$r[0];
|
||||
|
||||
$author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||
|
@ -245,7 +245,7 @@ function localize_item(&$item){
|
|||
$r = q("SELECT * from `item`,`contact` WHERE
|
||||
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
|
||||
dbesc($item['parent-uri']));
|
||||
if(count($r)==0) return;
|
||||
if(!dbm::is_result($r)) return;
|
||||
$obj=$r[0];
|
||||
|
||||
$author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
|
||||
|
@ -294,7 +294,7 @@ function localize_item(&$item){
|
|||
dbesc($obj->id),
|
||||
intval($item['uid'])
|
||||
);
|
||||
if(count($r) && $r[0]['plink']) {
|
||||
if(dbm::is_result($r) && $r[0]['plink']) {
|
||||
$target = $r[0];
|
||||
$Bname = $target['author-name'];
|
||||
$Blink = $target['author-link'];
|
||||
|
|
|
@ -552,7 +552,7 @@ function update_contact_birthdays() {
|
|||
// In-network birthdays are handled within local_delivery
|
||||
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
|
||||
logger('update_contact_birthday: ' . $rr['bd']);
|
||||
|
|
|
@ -53,7 +53,7 @@ function delivery_run(&$argv, &$argc){
|
|||
dbesc($item_id),
|
||||
dbesc($contact_id)
|
||||
);
|
||||
if (!count($r)) {
|
||||
if (!dbm::is_result($r)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ function delivery_run(&$argv, &$argc){
|
|||
intval($item_id)
|
||||
);
|
||||
|
||||
if ((!count($r)) || (!intval($r[0]['parent']))) {
|
||||
if ((!dbm::is_result($r)) || (!intval($r[0]['parent']))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ function delivery_run(&$argv, &$argc){
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (!count($r))
|
||||
if (!dbm::is_result($r))
|
||||
continue;
|
||||
|
||||
$owner = $r[0];
|
||||
|
@ -254,7 +254,7 @@ function delivery_run(&$argv, &$argc){
|
|||
intval($contact_id)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$contact = $r[0];
|
||||
|
||||
if ($contact['self'])
|
||||
|
@ -423,7 +423,7 @@ function delivery_run(&$argv, &$argc){
|
|||
intval($argv[2]),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$it = $r[0];
|
||||
}
|
||||
if (!$it)
|
||||
|
@ -478,14 +478,14 @@ function delivery_run(&$argv, &$argc){
|
|||
dbesc($it['parent-uri']),
|
||||
intval($uid));
|
||||
|
||||
if (count($r) AND ($r[0]['title'] != ''))
|
||||
if (dbm::is_result($r) AND ($r[0]['title'] != ''))
|
||||
$subject = $r[0]['title'];
|
||||
else {
|
||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($it['parent-uri']),
|
||||
intval($uid));
|
||||
|
||||
if (count($r) AND ($r[0]['title'] != ''))
|
||||
if (dbm::is_result($r) AND ($r[0]['title'] != ''))
|
||||
$subject = $r[0]['title'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ class dfrn {
|
|||
dbesc($owner_nick)
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
if(! dbm::is_result($r))
|
||||
killme();
|
||||
|
||||
$owner = $r[0];
|
||||
|
@ -139,7 +139,7 @@ class dfrn {
|
|||
intval($owner_id)
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
if(! dbm::is_result($r))
|
||||
killme();
|
||||
|
||||
$contact = $r[0];
|
||||
|
@ -1463,7 +1463,7 @@ class dfrn {
|
|||
dbesc(normalise_link($suggest["url"])),
|
||||
intval($suggest["uid"])
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return false;
|
||||
|
||||
// Do we already have an fcontact record for this person?
|
||||
|
@ -1474,7 +1474,7 @@ class dfrn {
|
|||
dbesc($suggest["name"]),
|
||||
dbesc($suggest["request"])
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$fid = $r[0]["id"];
|
||||
|
||||
// OK, we do. Do we already have an introduction for this person ?
|
||||
|
@ -1482,7 +1482,7 @@ class dfrn {
|
|||
intval($suggest["uid"]),
|
||||
intval($fid)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return false;
|
||||
}
|
||||
if(!$fid)
|
||||
|
@ -1497,7 +1497,7 @@ class dfrn {
|
|||
dbesc($suggest["name"]),
|
||||
dbesc($suggest["request"])
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$fid = $r[0]["id"];
|
||||
else
|
||||
// database record did not get created. Quietly give up.
|
||||
|
@ -1746,7 +1746,7 @@ class dfrn {
|
|||
LIMIT 1",
|
||||
dbesc($item["parent-uri"])
|
||||
);
|
||||
if($r && count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
|
||||
|
@ -1758,7 +1758,7 @@ class dfrn {
|
|||
dbesc($r[0]["parent-uri"]),
|
||||
intval($importer["importer_uid"])
|
||||
);
|
||||
if($r && count($r))
|
||||
if(dbm::is_result($r))
|
||||
$is_a_remote_action = true;
|
||||
}
|
||||
|
||||
|
@ -1898,7 +1898,7 @@ class dfrn {
|
|||
dbesc($item["verb"]),
|
||||
dbesc($item["parent-uri"])
|
||||
);
|
||||
if($r && count($r))
|
||||
if(dbm::is_result($r))
|
||||
return false;
|
||||
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
|
||||
|
@ -1907,7 +1907,7 @@ class dfrn {
|
|||
dbesc($item["verb"]),
|
||||
dbesc($item["parent-uri"])
|
||||
);
|
||||
if($r && count($r))
|
||||
if(dbm::is_result($r))
|
||||
return false;
|
||||
} else
|
||||
$is_like = false;
|
||||
|
@ -1923,7 +1923,7 @@ class dfrn {
|
|||
intval($importer["importer_uid"])
|
||||
);
|
||||
|
||||
if(!count($r))
|
||||
if(!dbm::is_result($r))
|
||||
return false;
|
||||
|
||||
// extract tag, if not duplicate, add to parent item
|
||||
|
@ -2195,7 +2195,7 @@ class dfrn {
|
|||
dbesc($item["uri"]),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$ev["id"] = $r[0]["id"];
|
||||
|
||||
$event_id = event_store($ev);
|
||||
|
@ -2216,7 +2216,7 @@ class dfrn {
|
|||
}
|
||||
|
||||
// Update content if 'updated' changes
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
if (self::update_content($r[0], $item, $importer, $entrytype))
|
||||
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
|
||||
else
|
||||
|
@ -2238,7 +2238,7 @@ class dfrn {
|
|||
intval($posted_id),
|
||||
intval($importer["importer_uid"])
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$parent = $r[0]["parent"];
|
||||
$parent_uri = $r[0]["parent-uri"];
|
||||
}
|
||||
|
@ -2326,7 +2326,7 @@ class dfrn {
|
|||
intval($importer["uid"]),
|
||||
intval($importer["id"])
|
||||
);
|
||||
if(!count($r)) {
|
||||
if(!dbm::is_result($r)) {
|
||||
logger("Item with uri ".$uri." from contact ".$importer["id"]." for user ".$importer["uid"]." wasn't found.", LOGGER_DEBUG);
|
||||
return;
|
||||
} else {
|
||||
|
@ -2420,7 +2420,7 @@ class dfrn {
|
|||
dbesc($item["parent-uri"]),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($r[0]["id"])
|
||||
);
|
||||
|
|
|
@ -411,7 +411,7 @@ function notification($params) {
|
|||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$dups = true;
|
||||
} while($dups == true);
|
||||
|
||||
|
@ -733,7 +733,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
|||
intval($item[0]['contact-id']),
|
||||
intval($uid)
|
||||
);
|
||||
$send_notification = count($r);
|
||||
$send_notification = dbm::is_result($r);
|
||||
|
||||
if (!$send_notification) {
|
||||
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
|
||||
|
@ -743,7 +743,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
|||
foreach ($tags AS $tag) {
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
|
||||
normalise_link($tag["url"]), intval($uid));
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$send_notification = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ function event_store($arr) {
|
|||
intval($arr['id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if((! count($r)) || ($r[0]['edited'] === $arr['edited'])) {
|
||||
if((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
|
||||
|
||||
// Nothing has changed. Grab the item id to return.
|
||||
|
||||
|
@ -279,7 +279,7 @@ function event_store($arr) {
|
|||
intval($arr['id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
return((count($r)) ? $r[0]['id'] : 0);
|
||||
return((dbm::is_result($r)) ? $r[0]['id'] : 0);
|
||||
}
|
||||
|
||||
// The event changed. Update it.
|
||||
|
@ -312,7 +312,7 @@ function event_store($arr) {
|
|||
intval($arr['id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
|
||||
$object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
|
||||
$object .= '</object>' . "\n";
|
||||
|
@ -365,7 +365,7 @@ function event_store($arr) {
|
|||
dbesc($arr['uri']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$event = $r[0];
|
||||
|
||||
$item_arr = array();
|
||||
|
@ -407,7 +407,7 @@ function event_store($arr) {
|
|||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($arr['uid'])
|
||||
);
|
||||
//if(count($r))
|
||||
//if(dbm::is_result($r))
|
||||
// $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
|
||||
|
||||
|
||||
|
@ -515,7 +515,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
|
|||
intval($event_params["event_id"])
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
|
|||
dbesc($event_params["adjust_finish"])
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
|
|||
);
|
||||
}
|
||||
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,7 @@ function event_export($uid, $format = 'ical') {
|
|||
// we are allowed to show events
|
||||
// get the timezone the user is in
|
||||
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$timezone = $r[0]['timezone'];
|
||||
|
||||
// get all events which are owned by a uid (respects permissions);
|
||||
|
|
|
@ -39,7 +39,7 @@ function expire_run(&$argv, &$argc){
|
|||
logger('expire: start');
|
||||
|
||||
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
|
||||
item_expire($rr['uid'],$rr['expire']);
|
||||
|
|
|
@ -10,7 +10,7 @@ function fcontact_store($url,$name,$photo) {
|
|||
dbesc($nurl)
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r[0]['id'];
|
||||
|
||||
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
|
||||
|
@ -19,11 +19,11 @@ function fcontact_store($url,$name,$photo) {
|
|||
dbesc($photo)
|
||||
);
|
||||
|
||||
if($r) {
|
||||
if(dbm::is_result($r)) {
|
||||
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
|
||||
dbesc($nurl)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r[0]['id'];
|
||||
}
|
||||
|
||||
|
|
|
@ -173,12 +173,12 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if(!count($r))
|
||||
if(!dbm::is_result($r))
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
// update contact
|
||||
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
|
||||
q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d",
|
||||
|
@ -196,7 +196,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
$r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0",
|
||||
intval($uid)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$total_contacts = $r[0]['total'];
|
||||
|
||||
if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
|
||||
|
@ -208,7 +208,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
intval($uid),
|
||||
dbesc($network)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$total_network = $r[0]['total'];
|
||||
|
||||
if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
|
||||
|
@ -250,7 +250,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if(! count($r)) {
|
||||
if(! dbm::is_result($r)) {
|
||||
$result['message'] .= t('Unable to retrieve contact information.') . EOL;
|
||||
return $result;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
|
||||
require_once('include/salmon.php');
|
||||
slapper($r[0],$contact['notify'],$slap);
|
||||
|
|
|
@ -44,7 +44,7 @@ function group_rmv($uid,$name) {
|
|||
intval($uid),
|
||||
dbesc($name)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$group_id = $r[0]['id'];
|
||||
if(! $group_id)
|
||||
return false;
|
||||
|
@ -106,7 +106,7 @@ function group_byname($uid,$name) {
|
|||
intval($uid),
|
||||
dbesc($name)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return $r[0]['id'];
|
||||
return false;
|
||||
}
|
||||
|
@ -139,11 +139,11 @@ function group_add_member($uid,$name,$member,$gid = 0) {
|
|||
intval($gid),
|
||||
intval($member)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
return true; // You might question this, but
|
||||
// we indicate success because the group member was in fact created
|
||||
// -- It was just created at another time
|
||||
if(! count($r))
|
||||
if(! dbm::is_result($r))
|
||||
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
|
||||
VALUES( %d, %d, %d ) ",
|
||||
intval($uid),
|
||||
|
@ -164,7 +164,7 @@ function group_get_members($gid) {
|
|||
intval($gid),
|
||||
intval(local_user())
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$ret = $r;
|
||||
}
|
||||
return $ret;
|
||||
|
@ -181,7 +181,7 @@ function group_public_members($gid) {
|
|||
intval(local_user()),
|
||||
dbesc(NETWORK_OSTATUS)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$ret = count($r);
|
||||
}
|
||||
return $ret;
|
||||
|
@ -197,7 +197,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
|
|||
intval($uid)
|
||||
);
|
||||
$grps[] = array('name' => '', 'id' => '0', 'selected' => '');
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
|
|||
$member_of = groups_containing(local_user(),$cid);
|
||||
}
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
|
||||
|
||||
|
@ -316,7 +316,7 @@ function expand_groups($a,$check_dead = false, $use_gcontact = false) {
|
|||
|
||||
|
||||
$ret = array();
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
foreach($r as $rr)
|
||||
$ret[] = $rr['contact-id'];
|
||||
if($check_dead AND !$use_gcontact) {
|
||||
|
@ -345,7 +345,7 @@ function groups_containing($uid,$c) {
|
|||
);
|
||||
|
||||
$ret = array();
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr)
|
||||
$ret[] = $rr['gid'];
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
|
|||
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($visitor['cid'])
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$profile = $r[0]['profile-id'];
|
||||
break;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
|
|||
intval($profile_int)
|
||||
);
|
||||
}
|
||||
if((!$r) && (!count($r))) {
|
||||
if(!dbm::is_result($r)) {
|
||||
$r = q("SELECT `contact`.`id` AS `contact_id`, `profile`.`uid` AS `profile_uid`, `profile`.*,
|
||||
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
|
||||
FROM `profile`
|
||||
|
@ -236,7 +236,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
|
||||
$r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
|
||||
local_user(), $profile_url);
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$connect = false;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
'entries' => array(),
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
|
||||
foreach($r as $rr) {
|
||||
$profile['menu']['entries'][] = array(
|
||||
|
@ -368,7 +368,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
if(is_array($a->profile) AND !$a->profile['hide-friends']) {
|
||||
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
|
||||
intval($a->profile['uid']));
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$updated = date("c", strtotime($r[0]['updated']));
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
|
||||
|
@ -378,7 +378,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
dbesc(NETWORK_DIASPORA),
|
||||
dbesc(NETWORK_OSTATUS)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$contacts = intval($r[0]['total']);
|
||||
}
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ function get_birthdays() {
|
|||
dbesc(datetime_convert('UTC','UTC','now'))
|
||||
);
|
||||
|
||||
if($r && count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$total = 0;
|
||||
$now = strtotime('now');
|
||||
$cids = array();
|
||||
|
@ -543,7 +543,7 @@ function get_events() {
|
|||
dbesc(datetime_convert('UTC','UTC','now - 1 days'))
|
||||
);
|
||||
|
||||
if($r && count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$now = strtotime('now');
|
||||
$istoday = false;
|
||||
foreach($r as $rr) {
|
||||
|
|
|
@ -451,7 +451,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
/* check for create date and expire time */
|
||||
$uid = intval($arr['uid']);
|
||||
$r = q("SELECT expire FROM user WHERE uid = %d", intval($uid));
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$expire_interval = $r[0]['expire'];
|
||||
if ($expire_interval>0) {
|
||||
$expire_date = new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC'));
|
||||
|
@ -568,19 +568,19 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
if (!count($r))
|
||||
if (!dbm::is_result($r))
|
||||
$r = q("SELECT `network` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND `nurl` = '%s' LIMIT 1",
|
||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS),
|
||||
dbesc(normalise_link($arr['author-link']))
|
||||
);
|
||||
|
||||
if (!count($r))
|
||||
if (!dbm::is_result($r))
|
||||
$r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($arr['contact-id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
$arr['network'] = $r[0]["network"];
|
||||
|
||||
// Fallback to friendica (why is it empty in some cases?)
|
||||
|
@ -634,7 +634,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
$r = q("SELECT `guid` FROM `item` WHERE `guid` = '%s' AND `network` = '%s' AND `uid` = '%d' LIMIT 1",
|
||||
dbesc($arr['guid']), dbesc($arr['network']), intval($arr['uid']));
|
||||
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG);
|
||||
return 0;
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
|
||||
// is the new message multi-level threaded?
|
||||
// even though we don't support it now, preserve the info
|
||||
|
@ -1120,7 +1120,7 @@ function item_body_set_hashtags(&$item) {
|
|||
|
||||
function get_item_guid($id) {
|
||||
$r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id));
|
||||
if (count($r))
|
||||
if (dbm::is_result($r))
|
||||
return($r[0]["guid"]);
|
||||
else
|
||||
return("");
|
||||
|
@ -1139,7 +1139,7 @@ function get_item_id($guid, $uid = 0) {
|
|||
$r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid));
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$id = $r[0]["id"];
|
||||
$nick = $r[0]["nickname"];
|
||||
}
|
||||
|
@ -1153,7 +1153,7 @@ function get_item_id($guid, $uid = 0) {
|
|||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
AND `item`.`private` = 0 AND `item`.`wall` = 1
|
||||
AND `item`.`guid` = '%s'", dbesc($guid));
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$id = $r[0]["id"];
|
||||
$nick = $r[0]["nickname"];
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ function item_is_remote_self($contact, &$datarray) {
|
|||
if ($contact['remote_self'] == 2) {
|
||||
$r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`",
|
||||
intval($contact['uid']));
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$datarray['contact-id'] = $r[0]["id"];
|
||||
|
||||
$datarray['owner-name'] = $r[0]["name"];
|
||||
|
@ -1531,7 +1531,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
);
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
$contact_record = $r[0];
|
||||
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
|
||||
}
|
||||
|
@ -1541,7 +1541,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
intval($importer['uid'])
|
||||
);
|
||||
$a = get_app();
|
||||
if (count($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
if (dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
|
@ -1580,7 +1580,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
));
|
||||
|
||||
}
|
||||
} elseif (count($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
} elseif (dbm::is_result($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
$r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
|
@ -1628,7 +1628,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 ((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
|
||||
if ((! dbm::is_result($r)) || $contact['network'] === NETWORK_DIASPORA)
|
||||
return;
|
||||
|
||||
$push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
|
||||
|
@ -1846,7 +1846,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
|
|||
intval($days)
|
||||
);
|
||||
|
||||
if (! count($r))
|
||||
if (! dbm::is_result($r))
|
||||
return;
|
||||
|
||||
$expire_items = get_pconfig($uid, 'expire','items');
|
||||
|
@ -1924,7 +1924,7 @@ function drop_item($id,$interactive = true) {
|
|||
intval($id)
|
||||
);
|
||||
|
||||
if (! count($r)) {
|
||||
if (! dbm::is_result($r)) {
|
||||
if (! $interactive)
|
||||
return 0;
|
||||
notice( t('Item not found.') . EOL);
|
||||
|
@ -2111,7 +2111,7 @@ function drop_item($id,$interactive = true) {
|
|||
dbesc($item['parent-uri']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
|
@ -2147,7 +2147,7 @@ function first_post_date($uid,$wall = false) {
|
|||
intval($uid),
|
||||
intval($wall ? 1 : 0)
|
||||
);
|
||||
if (count($r)) {
|
||||
if (dbm::is_result($r)) {
|
||||
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
|
||||
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ function do_like($item_id, $verb) {
|
|||
dbesc($item_id)
|
||||
);
|
||||
|
||||
if(! $item_id || (! count($r))) {
|
||||
if(! $item_id || (! dbm::is_result($r))) {
|
||||
logger('like: no item ' . $item_id);
|
||||
return false;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ function do_like($item_id, $verb) {
|
|||
intval($item['contact-id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
if(! count($r))
|
||||
if(! dbm::is_result($r))
|
||||
return false;
|
||||
if(! $r[0]['self'])
|
||||
$remote_owner = $r[0];
|
||||
|
@ -90,7 +90,7 @@ function do_like($item_id, $verb) {
|
|||
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
|
||||
intval($owner_uid)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$owner = $r[0];
|
||||
|
||||
if(! $owner) {
|
||||
|
@ -112,7 +112,7 @@ function do_like($item_id, $verb) {
|
|||
intval($_SESSION['visitor_id']),
|
||||
intval($owner_uid)
|
||||
);
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
$contact = $r[0];
|
||||
}
|
||||
if(! $contact) {
|
||||
|
@ -135,7 +135,7 @@ function do_like($item_id, $verb) {
|
|||
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$like_item = $r[0];
|
||||
|
||||
// Already voted, undo it
|
||||
|
|
|
@ -16,14 +16,14 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
|
|||
dbesc($fn_name)
|
||||
);
|
||||
|
||||
if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
|
||||
if((dbm::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
|
||||
q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($fn_name)
|
||||
);
|
||||
$got_lock = true;
|
||||
}
|
||||
elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
|
||||
elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
|
||||
q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
|
||||
dbesc($fn_name),
|
||||
dbesc(datetime_convert())
|
||||
|
@ -56,10 +56,10 @@ function block_on_function_lock($fn_nam |