Merge branch 'rewrites/dbm_is_result' into develop

This commit is contained in:
Roland Häder 2016-12-19 14:47:05 +01:00
commit dac1dbd3e9
11 changed files with 20 additions and 19 deletions

View file

@ -227,14 +227,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'",

View file

@ -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

View file

@ -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) {

View file

@ -953,8 +953,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
@ -2227,7 +2227,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;

View file

@ -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())

View file

@ -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));
}

View file

@ -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);

View file

@ -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));

View file

@ -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)

View file

@ -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');

View file

@ -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",