mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
[Scrutinizer] Fix undeclared variables in src/ (except Protocol/)
- Use dba::selectFirst to remove intermediate variables `$r` - Remove unused variable `$url_recipients` in Worker\Dellivery
This commit is contained in:
parent
2234bb92ae
commit
d419d07f73
17 changed files with 89 additions and 81 deletions
|
@ -76,6 +76,7 @@ class Cache
|
|||
$seconds = 300;
|
||||
break;
|
||||
case CACHE_MINUTE:
|
||||
default:
|
||||
$seconds = 60;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -389,9 +389,10 @@ class Worker
|
|||
if (Config::get("system", "profiler")) {
|
||||
$duration = microtime(true)-$a->performance["start"];
|
||||
|
||||
$o = '';
|
||||
if (Config::get("rendertime", "callstack")) {
|
||||
if (isset($a->callstack["database"])) {
|
||||
$o = "\nDatabase Read:\n";
|
||||
$o .= "\nDatabase Read:\n";
|
||||
foreach ($a->callstack["database"] as $func => $time) {
|
||||
$time = round($time, 3);
|
||||
if ($time > 0) {
|
||||
|
@ -417,8 +418,6 @@ class Worker
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$o = '';
|
||||
}
|
||||
|
||||
logger(
|
||||
|
@ -564,6 +563,7 @@ class Worker
|
|||
// We killed the stale process.
|
||||
// To avoid a blocking situation we reschedule the process at the beginning of the queue.
|
||||
// Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
|
||||
$new_priority = $entry["priority"];
|
||||
if ($entry["priority"] == PRIORITY_HIGH) {
|
||||
$new_priority = PRIORITY_MEDIUM;
|
||||
} elseif ($entry["priority"] == PRIORITY_MEDIUM) {
|
||||
|
@ -768,7 +768,7 @@ class Worker
|
|||
$limit = min($queue_length, ceil($slope * pow($jobs, $exponent)));
|
||||
|
||||
logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG);
|
||||
|
||||
$ids = [];
|
||||
if (self::passingSlow($highest_priority)) {
|
||||
// Are there waiting processes with a higher priority than the currently highest?
|
||||
$result = dba::select(
|
||||
|
|
|
@ -244,19 +244,18 @@ class DBStructure
|
|||
|
||||
// Compare it
|
||||
foreach ($definition AS $name => $structure) {
|
||||
$is_new_table = False;
|
||||
$is_new_table = false;
|
||||
$group_by = "";
|
||||
$sql3 = "";
|
||||
$is_unique = false;
|
||||
$temp_name = $name;
|
||||
if (!isset($database[$name])) {
|
||||
$r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
|
||||
if (!DBM::is_result($r)) {
|
||||
$errors .= self::printUpdateError($name);
|
||||
}
|
||||
$is_new_table = True;
|
||||
$is_new_table = true;
|
||||
} else {
|
||||
$is_unique = false;
|
||||
$temp_name = $name;
|
||||
|
||||
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
|
||||
if (isset($database[$name]["indexes"][$indexname])) {
|
||||
$current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
|
||||
|
@ -463,7 +462,7 @@ class DBStructure
|
|||
if ($ignore != "") {
|
||||
dba::e("SET session old_alter_table=1;");
|
||||
} else {
|
||||
dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
|
||||
$r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
|
||||
if (!DBM::is_result($r)) {
|
||||
$errors .= self::printUpdateError($sql3);
|
||||
return $errors;
|
||||
|
|
|
@ -1365,6 +1365,7 @@ class Contact extends BaseObject
|
|||
$url = notags(trim($datarray['author-link']));
|
||||
$name = notags(trim($datarray['author-name']));
|
||||
$photo = notags(trim($datarray['author-avatar']));
|
||||
$nick = '';
|
||||
|
||||
if (is_object($item)) {
|
||||
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
|
||||
|
@ -1398,20 +1399,16 @@ class Contact extends BaseObject
|
|||
intval(CONTACT_IS_FOLLOWER)
|
||||
);
|
||||
|
||||
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$contact_record = $r[0];
|
||||
Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
|
||||
}
|
||||
$contact_record = [
|
||||
'id' => dba::lastInsertId(),
|
||||
'network' => NETWORK_OSTATUS
|
||||
];
|
||||
Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
|
||||
|
||||
/// @TODO Encapsulate this into a function/method
|
||||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($importer['uid'])
|
||||
);
|
||||
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
|
||||
$user = dba::selectFirst('user', $fields, ['uid' => $importer['uid']]);
|
||||
if (DBM::is_result($user) && !in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
|
||||
|
@ -1423,16 +1420,16 @@ class Contact extends BaseObject
|
|||
|
||||
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
|
||||
|
||||
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
in_array($r[0]['page-flags'], [PAGE_NORMAL])) {
|
||||
if (($user['notify-flags'] & NOTIFY_INTRO) &&
|
||||
in_array($user['page-flags'], [PAGE_NORMAL])) {
|
||||
|
||||
notification([
|
||||
'type' => NOTIFY_INTRO,
|
||||
'notify_flags' => $r[0]['notify-flags'],
|
||||
'language' => $r[0]['language'],
|
||||
'to_name' => $r[0]['username'],
|
||||
'to_email' => $r[0]['email'],
|
||||
'uid' => $r[0]['uid'],
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'link' => System::baseUrl() . '/notifications/intro',
|
||||
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
|
||||
'source_link' => $contact_record['url'],
|
||||
|
@ -1442,13 +1439,12 @@ class Contact extends BaseObject
|
|||
]);
|
||||
|
||||
}
|
||||
} elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
} elseif (DBM::is_result($user) && in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,8 @@ class GContact
|
|||
{
|
||||
$gcontact_id = 0;
|
||||
$doprobing = false;
|
||||
$last_failure_str = '';
|
||||
$last_contact_str = '';
|
||||
|
||||
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
|
||||
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
|
||||
|
|
|
@ -251,9 +251,8 @@ class Item extends BaseObject
|
|||
$arr['network'] = trim(defaults($arr, 'network', NETWORK_PHANTOM));
|
||||
}
|
||||
|
||||
if ($notify) {
|
||||
$guid_prefix = "";
|
||||
} elseif ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
|
||||
$guid_prefix = '';
|
||||
if ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
|
||||
$arr['guid'] = self::guidFromUri($arr['plink']);
|
||||
} elseif ((trim($arr['guid']) == "") && (trim($arr['uri']) != "")) {
|
||||
$arr['guid'] = self::guidFromUri($arr['uri']);
|
||||
|
@ -521,6 +520,11 @@ class Item extends BaseObject
|
|||
|
||||
$arr['thr-parent'] = $arr['parent-uri'];
|
||||
|
||||
$notify_type = '';
|
||||
$allow_cid = '';
|
||||
$allow_gid = '';
|
||||
$deny_cid = '';
|
||||
$deny_gid = '';
|
||||
if ($arr['parent-uri'] === $arr['uri']) {
|
||||
$parent_id = 0;
|
||||
$parent_deleted = 0;
|
||||
|
|
|
@ -67,6 +67,7 @@ class Mail
|
|||
}
|
||||
}
|
||||
|
||||
$convuri = '';
|
||||
if (!$convid) {
|
||||
// create a new conversation
|
||||
$recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3);
|
||||
|
|
|
@ -91,6 +91,9 @@ class Photo
|
|||
*/
|
||||
public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
|
||||
{
|
||||
$thumb = '';
|
||||
$micro = '';
|
||||
|
||||
$photo = dba::selectFirst(
|
||||
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
|
||||
);
|
||||
|
|
|
@ -565,8 +565,10 @@ class Profile
|
|||
Cache::set($cachekey, $r, CACHE_HOUR);
|
||||
}
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$classtoday = '';
|
||||
if (DBM::is_result($r)) {
|
||||
$total = 0;
|
||||
$now = strtotime('now');
|
||||
$cids = [];
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ class User
|
|||
*/
|
||||
private static function getAuthenticationInfo($user_info)
|
||||
{
|
||||
$user = null;
|
||||
|
||||
if (is_object($user_info) || is_array($user_info)) {
|
||||
if (is_object($user_info)) {
|
||||
$user = (array) $user_info;
|
||||
|
|
|
@ -1542,29 +1542,31 @@ class Probe
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($uid != 0) {
|
||||
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
|
||||
if ($uid == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
|
||||
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
|
||||
|
||||
if (DBM::is_result($x) && DBM::is_result($r)) {
|
||||
$mailbox = Email::constructMailboxName($r[0]);
|
||||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
|
||||
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
|
||||
if (!mbox) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
|
||||
|
||||
$msgs = Email::poll($mbox, $uri);
|
||||
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
|
||||
|
||||
if (!count($msgs)) {
|
||||
if (DBM::is_result($x) && DBM::is_result($r)) {
|
||||
$mailbox = Email::constructMailboxName($r[0]);
|
||||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
|
||||
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
|
||||
if (!$mbox) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$msgs = Email::poll($mbox, $uri);
|
||||
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
|
||||
|
||||
if (!count($msgs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$phost = substr($uri, strpos($uri, '@') + 1);
|
||||
|
||||
$data = [];
|
||||
|
|
|
@ -50,19 +50,11 @@ class ParseUrl
|
|||
return false;
|
||||
}
|
||||
|
||||
$r = q(
|
||||
"SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d",
|
||||
dbesc(normalise_link($url)),
|
||||
intval(!$no_guessing),
|
||||
intval($do_oembed)
|
||||
$parsed_url = dba::selectFirst('parsed_url', ['content'],
|
||||
['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
|
||||
);
|
||||
|
||||
if ($r) {
|
||||
$data = $r[0]["content"];
|
||||
}
|
||||
|
||||
if (!is_null($data)) {
|
||||
$data = unserialize($data);
|
||||
if (!empty($parsed_url['content'])) {
|
||||
$data = unserialize($parsed_url['content']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ class XML
|
|||
}
|
||||
}
|
||||
|
||||
$element = null;
|
||||
foreach ($array as $key => $value) {
|
||||
if (!isset($element) && isset($xml)) {
|
||||
$element = $xml;
|
||||
|
@ -185,12 +186,13 @@ class XML
|
|||
return(null);
|
||||
}
|
||||
|
||||
$xml_element_copy = '';
|
||||
if (!is_string($xml_element)
|
||||
&& !is_array($xml_element)
|
||||
&& (get_class($xml_element) == 'SimpleXMLElement')
|
||||
) {
|
||||
$xml_element_copy = $xml_element;
|
||||
$xml_element = get_object_vars($xml_element);
|
||||
$xml_element_copy = $xml_element;
|
||||
$xml_element = get_object_vars($xml_element);
|
||||
}
|
||||
|
||||
if (is_array($xml_element)) {
|
||||
|
|
|
@ -34,11 +34,12 @@ class Delivery {
|
|||
$relocate = false;
|
||||
$top_level = false;
|
||||
$recipients = [];
|
||||
$url_recipients = [];
|
||||
$followup = false;
|
||||
|
||||
$normal_mode = true;
|
||||
|
||||
$item = null;
|
||||
|
||||
$recipients[] = $contact_id;
|
||||
|
||||
if ($cmd === 'mail') {
|
||||
|
@ -182,16 +183,14 @@ class Delivery {
|
|||
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
|
||||
intval($contact_id)
|
||||
// We don't deliver our items to blocked or pending contacts, and not to ourselves either
|
||||
$contact = dba::selectFirst('contact', [],
|
||||
['id' => $contact_id, 'blocked' => false, 'pending' => false, 'self' => false]
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$contact = $r[0];
|
||||
}
|
||||
if ($contact['self']) {
|
||||
if (!DBM::is_result($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$deliver_status = 0;
|
||||
|
||||
// Transmit via Diaspora if not possible via Friendica
|
||||
|
@ -207,7 +206,7 @@ class Delivery {
|
|||
logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']);
|
||||
|
||||
if ($mail) {
|
||||
$item['body'] = Item::fixPrivatePhotos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
|
||||
$item['body'] = Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
|
||||
$atom = DFRN::mail($item, $owner);
|
||||
} elseif ($fsuggest) {
|
||||
$atom = DFRN::fsuggest($item, $owner);
|
||||
|
|
|
@ -30,6 +30,8 @@ class DiscoverPoCo {
|
|||
- check_profile: Update remote profile data
|
||||
*/
|
||||
|
||||
$search = "";
|
||||
$mode = 0;
|
||||
if ($command == "dirsearch") {
|
||||
$search = urldecode($param1);
|
||||
$mode = 1;
|
||||
|
@ -47,10 +49,7 @@ class DiscoverPoCo {
|
|||
$mode = 7;
|
||||
} elseif ($command == "check_profile") {
|
||||
$mode = 8;
|
||||
} elseif ($command == '') {
|
||||
$search = "";
|
||||
$mode = 0;
|
||||
} else {
|
||||
} elseif ($command !== "") {
|
||||
logger("Unknown or missing parameter ".$command."\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ class Notifier {
|
|||
$url_recipients = [];
|
||||
|
||||
$normal_mode = true;
|
||||
$recipients_relocate = [];
|
||||
|
||||
if ($cmd === 'mail') {
|
||||
$normal_mode = false;
|
||||
|
@ -178,6 +179,10 @@ class Notifier {
|
|||
// fill this in with a single salmon slap if applicable
|
||||
$slap = '';
|
||||
|
||||
$followup = false;
|
||||
$recipients_followup = [];
|
||||
$conversants = [];
|
||||
$sql_extra = '';
|
||||
if (! ($mail || $fsuggest || $relocate)) {
|
||||
|
||||
$slap = OStatus::salmon($target_item, $owner);
|
||||
|
@ -321,8 +326,6 @@ class Notifier {
|
|||
Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id);
|
||||
}
|
||||
|
||||
$conversants = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
$recipients[] = $item['contact-id'];
|
||||
$conversants[] = $item['contact-id'];
|
||||
|
@ -519,7 +522,7 @@ class Notifier {
|
|||
// except for Diaspora batch jobs
|
||||
// Don't deliver to folks who have already been delivered to
|
||||
|
||||
if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
|
||||
if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'], $conversants))) {
|
||||
logger('notifier: already delivered id=' . $rr['id']);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
$importer = $r[0];
|
||||
$url = '';
|
||||
|
||||
logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
|
||||
|
|
Loading…
Reference in a new issue