forked from friendica/friendica-addons
Don't use "count"
This commit is contained in:
parent
478ff41870
commit
5e4f985243
|
@ -55,6 +55,7 @@ use Friendica\Model\Photo;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
function statusnet_install()
|
||||
{
|
||||
|
@ -463,7 +464,7 @@ function statusnet_post_hook(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||
if (!count($orig_post)) {
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
|
@ -684,7 +685,7 @@ function statusnet_prepare_body(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||
if (count($orig_post)) {
|
||||
if (DBM::is_result($orig_post)) {
|
||||
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
|
||||
|
||||
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
|
||||
|
@ -729,7 +730,7 @@ function statusnet_cron(App $a, $b)
|
|||
logger('statusnet: cron_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger('statusnet: fetching for user ' . $rr['uid']);
|
||||
statusnet_fetchtimeline($a, $rr['uid']);
|
||||
|
@ -744,11 +745,11 @@ function statusnet_cron(App $a, $b)
|
|||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` 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;
|
||||
}
|
||||
|
@ -901,16 +902,16 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
|||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
|
||||
|
||||
if (!count($r) && !$create_user) {
|
||||
if (!DBM::is_result($r) && !$create_user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
||||
if (DBM::is_result($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
||||
logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
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`,
|
||||
|
@ -940,7 +941,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
|||
intval($uid),
|
||||
dbesc(NETWORK_STATUSNET));
|
||||
|
||||
if (!count($r)) {
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1025,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
return;
|
||||
|
@ -1079,7 +1080,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1094,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
dbesc($parent),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$postarray['thr-parent'] = $r[0]["uri"];
|
||||
$postarray['parent-uri'] = $r[0]["parent-uri"];
|
||||
$postarray['parent'] = $r[0]["parent"];
|
||||
|
@ -1103,7 +1104,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
dbesc($parent),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$postarray['thr-parent'] = $r[0]['uri'];
|
||||
$postarray['parent-uri'] = $r[0]['parent-uri'];
|
||||
$postarray['parent'] = $r[0]['parent'];
|
||||
|
@ -1122,7 +1123,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$contactid = $r[0]["id"];
|
||||
|
||||
$postarray['owner-name'] = $r[0]["name"];
|
||||
|
@ -1226,7 +1227,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
intval($own_contact),
|
||||
intval($uid));
|
||||
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$nick = $r[0]["nick"];
|
||||
} else {
|
||||
logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1236,7 +1237,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1245,7 +1246,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
|
||||
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid));
|
||||
if (!count($u)) {
|
||||
if (!DBM::is_result($u)) {
|
||||
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
@ -1535,7 +1536,7 @@ function statusnet_fetch_own_contact(App $a, $uid)
|
|||
} else {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc($own_url));
|
||||
if (count($r)) {
|
||||
if (DBM::is_result($r)) {
|
||||
$contact_id = $r[0]["id"];
|
||||
} else {
|
||||
PConfig::delete($uid, 'statusnet', 'own_url');
|
||||
|
|
Loading…
Reference in a new issue