diff --git a/include/Contact.php b/include/Contact.php index 7ca45a21bd..16c663d2af 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -229,14 +229,14 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { dbesc(normalise_link($url)), intval($uid)); // Fetch the data from the contact table with "uid=0" (which is filled automatically) - if (!$r) + if (!dbm::is_result($r)) $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0", dbesc(normalise_link($url))); // Fetch the data from the gcontact table - if (!$r) + if (!dbm::is_result($r)) $r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`, `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self` FROM `gcontact` WHERE `nurl` = '%s'", diff --git a/include/api.php b/include/api.php index 2ae1aeaa02..df62abd8e6 100644 --- a/include/api.php +++ b/include/api.php @@ -3590,7 +3590,7 @@ intval($gid), dbesc($name)); // error message if specified gid is not in database - if (count($rname) == 0) + if (!dbm::is_result($rname)) throw new BadRequestException('wrong group name'); // delete group @@ -3629,7 +3629,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) throw new BadRequestException('group name already exists'); // check if specified group name is a deleted group @@ -3637,7 +3637,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) $reactivate_group = true; // create group diff --git a/include/cron.php b/include/cron.php index 77332dcec6..9530302d34 100644 --- a/include/cron.php +++ b/include/cron.php @@ -264,7 +264,7 @@ function cron_poll_contacts($argc, $argv) { intval($c['id']) ); - if((! $res) || (! count($res))) + if (dbm::is_result($res)) continue; foreach($res as $contact) { diff --git a/include/items.php b/include/items.php index da9147fadd..9507b5e5fe 100644 --- a/include/items.php +++ b/include/items.php @@ -956,8 +956,8 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // in it. if (!$deleted AND !$dontcache) { - $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post)); - if (count($r) == 1) { + $r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post)); + if ((dbm::is_result($r)) && (count($r) == 1)) { if ($notify) call_hooks('post_local_end', $r[0]); else @@ -2230,7 +2230,7 @@ function posted_date_widget($url,$uid,$wall) { $ret = list_post_dates($uid,$wall); - if (! count($ret)) + if (! dbm::is_result($ret)) return $o; $cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years; diff --git a/include/lock.php b/include/lock.php index 0c7b6acaa4..d49fda343f 100644 --- a/include/lock.php +++ b/include/lock.php @@ -23,7 +23,8 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) { ); $got_lock = true; } - elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r + elseif(! dbm::is_result($r)) { + /// @TODO 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()) diff --git a/include/plugin.php b/include/plugin.php index 487ab57515..2d5531f90b 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -129,7 +129,7 @@ function reload_plugins() { */ function plugin_enabled($plugin) { $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin); - return((bool)(count($r) > 0)); + return ((dbm::is_result($r)) && (count($r) > 0)); } diff --git a/include/poller.php b/include/poller.php index 44f4895cdb..d00360d2b7 100644 --- a/include/poller.php +++ b/include/poller.php @@ -213,7 +213,7 @@ function poller_max_connections_reached() { // The processlist only shows entries of the current user if ($max != 0) { $r = q("SHOW PROCESSLIST"); - if (!$r) + if (!dbm::is_result($r)) return false; $used = count($r); diff --git a/include/socgraph.php b/include/socgraph.php index 349fd0b2ca..f8a73a0a5c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1558,7 +1558,7 @@ function get_gcontact_id($contact) { proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($contact["url"])); } - if ((count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != "")) + if ((dbm::is_result($r)) AND (count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != "")) q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d", dbesc(normalise_link($contact["url"])), intval($gcontact_id)); diff --git a/include/user.php b/include/user.php index ec15d5b134..ae05b9e112 100644 --- a/include/user.php +++ b/include/user.php @@ -241,7 +241,7 @@ function create_user($arr) { WHERE `nickname` = '%s' ", dbesc($nickname) ); - if((count($r) > 1) && $newuid) { + if ((dbm::is_result($r)) && (count($r) > 1) && $newuid) { $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL; q("DELETE FROM `user` WHERE `uid` = %d", intval($newuid) diff --git a/mod/profiles.php b/mod/profiles.php index f9fde658d2..39e9a6c1ff 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -92,7 +92,7 @@ function profiles_init(&$a) { intval(local_user()), intval($a->argv[2]) ); - if(! count($r1)) { + if(! dbm::is_result($r1)) { notice( t('Profile unavailable to clone.') . EOL); killme(); return; @@ -116,7 +116,7 @@ function profiles_init(&$a) { dbesc($name) ); info( t('New profile created.') . EOL); - if(count($r3) == 1) + if ((dbm::is_result($r3)) && (count($r3) == 1)) goaway('profiles/'.$r3[0]['id']); goaway('profiles'); diff --git a/mod/regmod.php b/mod/regmod.php index 0120017b00..8caa964aa9 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -12,14 +12,14 @@ function user_allow($hash) { ); - if(! count($register)) + if(! dbm::is_result($register)) return false; $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']) ); - if(! count($user)) + if(! dbm::is_result($user)) killme(); $r = q("DELETE FROM `register` WHERE `hash` = '%s'", @@ -69,7 +69,7 @@ function user_deny($hash) { dbesc($hash) ); - if(! count($register)) + if(! dbm::is_result($register)) return false; $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",