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
commit 6a8a36f12d
115 changed files with 439 additions and 437 deletions

View file

@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($uid)
);
if(! count($r)) {
if(! dbm::is_result($r)) {
logger('Contact not found in DB.');
notice( t('Contact not found.') . EOL );
notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
@ -423,7 +423,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id)
);
if(count($r))
if(dbm::is_result($r))
$contact = $r[0];
else
$contact = null;
@ -443,7 +443,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($uid)
);
if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
require_once('include/items.php');
@ -553,7 +553,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($node));
if(! count($r)) {
if(! dbm::is_result($r)) {
$message = sprintf(t('No user record found for \'%s\' '), $node);
xml_status(3,$message); // failure
// NOTREACHED
@ -629,7 +629,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
dbesc($decrypted_dfrn_id)
);
if(count($r)) {
if(dbm::is_result($r)) {
$message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
xml_status(1,$message); // Birthday paradox - duplicate dfrn-id
// NOTREACHED
@ -640,7 +640,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($dfrn_pubkey),
intval($dfrn_record)
);
if(! count($r)) {
if(! dbm::is_result($r)) {
$message = t('Unable to set your contact credentials on our system.');
xml_status(3,$message);
}
@ -661,7 +661,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($dfrn_record));
if(count($r))
if(dbm::is_result($r))
$photo = $r[0]['photo'];
else
$photo = $a->get_baseurl() . '/images/person-175.jpg';
@ -714,10 +714,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($dfrn_record)
);
if(count($r))
if(dbm::is_result($r))
$combined = $r[0];
if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
@ -742,7 +742,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($local_uid)
);
if((count($r)) && ($r[0]['hide-friends'] == 0)) {
if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
require_once('include/items.php');