Fix: Wrong variable name in "if" / Some reworked parts

This commit is contained in:
Michael 2018-06-24 05:02:09 +00:00
parent f8916bf9d9
commit 337464c6b0

View file

@ -546,7 +546,7 @@ function pumpio_send(&$a,&$b) {
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user,true));
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
if (count($r))
if (DBM::is_result($r))
$a->contact = $r[0]["id"];
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $params]);
@ -618,7 +618,7 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "") {
logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user,true));
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
if (count($r))
if (DBM::is_result($r))
$a->contact = $r[0]["id"];
$s = serialize(['url' => $url, 'item' => $orig_post["id"], 'post' => $params]);
@ -632,7 +632,7 @@ function pumpio_sync(&$a) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'",
$plugin);
if (!count($r))
if (!DBM::is_result($r))
return;
$last = Config::get('pumpio','last_poll');
@ -651,7 +651,7 @@ function pumpio_sync(&$a) {
logger('pumpio: cron_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
if(count($r)) {
if (DBM::is_result($r)) {
foreach($r as $rr) {
logger('pumpio: mirroring user '.$rr['uid']);
pumpio_fetchtimeline($a, $rr['uid']);
@ -665,11 +665,11 @@ function pumpio_sync(&$a) {
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
if(count($r)) {
if (DBM::is_result($r)) {
foreach($r as $rr) {
if ($abandon_days != 0) {
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
if (!count($user)) {
if (!DBM::is_result($user)) {
logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
continue;
}
@ -823,9 +823,9 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
// Searching for the unliked post
// Two queries for speed issues
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
if (!DBM::is_result($r)) {
if (!DBM::is_result($orig_post)) {
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
if (!DBM::is_result($r)) {
if (!DBM::is_result($orig_post)) {
return;
}
}
@ -840,7 +840,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
intval($uid)
);
if(count($r))
if (DBM::is_result($r))
$contactid = $r[0]['id'];
if ($contactid == 0)
@ -849,7 +849,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
if(count($r))
if (DBM::is_result($r))
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
else
logger("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
@ -866,9 +866,9 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
// Searching for the liked post
// Two queries for speed issues
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
if (!DBM::is_result($r)) {
if (!DBM::is_result($orig_post)) {
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
if (!DBM::is_result($r)) {
if (!DBM::is_result($orig_post)) {
return;
}
}
@ -890,7 +890,7 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
intval($uid)
);
if(count($r))
if (DBM::is_result($r))
$contactid = $r[0]['id'];
if ($contactid == 0)
@ -947,7 +947,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval($uid), dbesc(normalise_link($contact->url)));
if (!count($r)) {
if (!DBM::is_result($r)) {
// create contact record
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
@ -977,7 +977,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) {
intval($uid)
);
if (!count($r)) {
if (!DBM::is_result($r)) {
return(false);
}
@ -1093,7 +1093,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
intval($uid)
);
if(count($r))
if (DBM::is_result($r))
$contact_id = $r[0]['id'];
else {
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
@ -1101,7 +1101,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
intval($uid)
);
if(count($r))
if (DBM::is_result($r))
$contact_id = $r[0]['id'];
else
$contact_id = $self[0]['id'];
@ -1308,7 +1308,7 @@ function pumpio_queue_hook(&$a,&$b) {
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_PUMPIO)
);
if(! count($qi))
if (!DBM::is_result($qi))
return;
foreach($qi as $x) {
@ -1321,7 +1321,7 @@ function pumpio_queue_hook(&$a,&$b) {
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
if(! count($r))
if (!DBM::is_result($r))
continue;
$userdata = $r[0];
@ -1408,7 +1408,7 @@ function pumpio_getreceiver(&$a, $b) {
dbesc(NETWORK_PUMPIO)
);
if (count($r)) {
if (DBM::is_result($r)) {
$receiver["bcc"][] = [
"displayName" => $r[0]["name"],
"objectType" => "person",
@ -1451,7 +1451,7 @@ function pumpio_getreceiver(&$a, $b) {
dbesc(NETWORK_PUMPIO)
);
if (count($r)) {
if (DBM::is_result($r)) {
$receiver["to"][] = [
"displayName" => $r[0]["name"],
"objectType" => "person",
@ -1482,7 +1482,7 @@ function pumpio_fetchallcomments(&$a, $uid, $id) {
// Fetching the original post
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
$item = Item::selectFirst(['extid'], $condition);
if (!DBM::is_result($r)) {
if (!DBM::is_result($item)) {
return false;
}