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:
Roland Häder 2016-12-13 10:44:13 +01:00
parent 293436e5fd
commit 6a8a36f12d
115 changed files with 439 additions and 437 deletions

View file

@ -42,7 +42,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage'])
);
if(count($r))
if(dbm::is_result($r))
$master_record = $r[0];
}
@ -50,7 +50,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
dbesc($master_record['password']),
dbesc($master_record['email'])
);
if($r && count($r))
if(dbm::is_result($r))
$a->identities = $r;
else
$a->identities = array();
@ -60,7 +60,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
and `manage`.`uid` = %d",
intval($master_record['uid'])
);
if($r && count($r))
if(dbm::is_result($r))
$a->identities = array_merge($a->identities,$r);
if($login_initial)
@ -70,7 +70,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid']));
if(count($r)) {
if(dbm::is_result($r)) {
$a->contact = $r[0];
$a->cid = $r[0]['id'];
$_SESSION['cid'] = $a->cid;
@ -156,7 +156,7 @@ function can_write_wall(&$a,$owner) {
intval(PAGE_COMMUNITY)
);
if(count($r)) {
if(dbm::is_result($r)) {
$verified = 2;
return true;
}
@ -210,7 +210,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
intval($remote_user),
intval($owner_id)
);
if(count($r)) {
if(dbm::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
@ -292,7 +292,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
intval($remote_user),
intval($owner_id)
);
if(count($r)) {
if(dbm::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
@ -403,7 +403,7 @@ function init_groups_visitor($contact_id) {
WHERE `contact-id` = %d ",
intval($contact_id)
);
if(count($r)) {
if(dbm::is_result($r)) {
foreach($r as $rr)
$groups[] = $rr['gid'];
}