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

pull/631/head
Michael 2018-06-24 05:02:09 +00:00
parent f8916bf9d9
commit 337464c6b0
1 changed files with 54 additions and 54 deletions

View File

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