mirror of
https://github.com/friendica/friendica
synced 2025-04-27 05:10:10 +00: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
115 changed files with 439 additions and 437 deletions
|
@ -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'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue