1
1
Fork 0

Merge pull request #4455 from MrPetovan/task/4176-fix-undeclared-variables-2

[Scrutinizer] Fix undeclared variables part 6: src/ (except Protocol/)
This commit is contained in:
Michael Vogel 2018-02-14 22:49:43 +01:00 committed by GitHub
commit 79696a19e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 89 additions and 81 deletions

View file

@ -76,6 +76,7 @@ class Cache
$seconds = 300; $seconds = 300;
break; break;
case CACHE_MINUTE: case CACHE_MINUTE:
default:
$seconds = 60; $seconds = 60;
break; break;
} }

View file

@ -389,9 +389,10 @@ class Worker
if (Config::get("system", "profiler")) { if (Config::get("system", "profiler")) {
$duration = microtime(true)-$a->performance["start"]; $duration = microtime(true)-$a->performance["start"];
$o = '';
if (Config::get("rendertime", "callstack")) { if (Config::get("rendertime", "callstack")) {
if (isset($a->callstack["database"])) { if (isset($a->callstack["database"])) {
$o = "\nDatabase Read:\n"; $o .= "\nDatabase Read:\n";
foreach ($a->callstack["database"] as $func => $time) { foreach ($a->callstack["database"] as $func => $time) {
$time = round($time, 3); $time = round($time, 3);
if ($time > 0) { if ($time > 0) {
@ -417,8 +418,6 @@ class Worker
} }
} }
} }
} else {
$o = '';
} }
logger( logger(
@ -564,6 +563,7 @@ class Worker
// We killed the stale process. // We killed the stale process.
// To avoid a blocking situation we reschedule the process at the beginning of the queue. // 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) // Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
$new_priority = $entry["priority"];
if ($entry["priority"] == PRIORITY_HIGH) { if ($entry["priority"] == PRIORITY_HIGH) {
$new_priority = PRIORITY_MEDIUM; $new_priority = PRIORITY_MEDIUM;
} elseif ($entry["priority"] == PRIORITY_MEDIUM) { } elseif ($entry["priority"] == PRIORITY_MEDIUM) {
@ -768,7 +768,7 @@ class Worker
$limit = min($queue_length, ceil($slope * pow($jobs, $exponent))); $limit = min($queue_length, ceil($slope * pow($jobs, $exponent)));
logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG); logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG);
$ids = [];
if (self::passingSlow($highest_priority)) { if (self::passingSlow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest? // Are there waiting processes with a higher priority than the currently highest?
$result = dba::select( $result = dba::select(

View file

@ -244,19 +244,18 @@ class DBStructure
// Compare it // Compare it
foreach ($definition AS $name => $structure) { foreach ($definition AS $name => $structure) {
$is_new_table = False; $is_new_table = false;
$group_by = ""; $group_by = "";
$sql3 = ""; $sql3 = "";
$is_unique = false;
$temp_name = $name;
if (!isset($database[$name])) { if (!isset($database[$name])) {
$r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']); $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($name); $errors .= self::printUpdateError($name);
} }
$is_new_table = True; $is_new_table = true;
} else { } else {
$is_unique = false;
$temp_name = $name;
foreach ($structure["indexes"] AS $indexname => $fieldnames) { foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) { if (isset($database[$name]["indexes"][$indexname])) {
$current_index_definition = implode(",",$database[$name]["indexes"][$indexname]); $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
@ -463,7 +462,7 @@ class DBStructure
if ($ignore != "") { if ($ignore != "") {
dba::e("SET session old_alter_table=1;"); dba::e("SET session old_alter_table=1;");
} else { } else {
dba::e("DROP TABLE IF EXISTS `".$temp_name."`;"); $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3); $errors .= self::printUpdateError($sql3);
return $errors; return $errors;

View file

@ -1365,6 +1365,7 @@ class Contact extends BaseObject
$url = notags(trim($datarray['author-link'])); $url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name'])); $name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar'])); $photo = notags(trim($datarray['author-avatar']));
$nick = '';
if (is_object($item)) { if (is_object($item)) {
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor'); $rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
@ -1398,20 +1399,16 @@ class Contact extends BaseObject
intval(CONTACT_IS_FOLLOWER) intval(CONTACT_IS_FOLLOWER)
); );
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", $contact_record = [
intval($importer['uid']), 'id' => dba::lastInsertId(),
dbesc($url) 'network' => NETWORK_OSTATUS
); ];
if (DBM::is_result($r)) { Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
$contact_record = $r[0];
Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
}
/// @TODO Encapsulate this into a function/method /// @TODO Encapsulate this into a function/method
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
intval($importer['uid']) $user = dba::selectFirst('user', $fields, ['uid' => $importer['uid']]);
); if (DBM::is_result($user) && !in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
// create notification // create notification
$hash = random_string(); $hash = random_string();
@ -1423,16 +1420,16 @@ class Contact extends BaseObject
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']); Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
if (($r[0]['notify-flags'] & NOTIFY_INTRO) && if (($user['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], [PAGE_NORMAL])) { in_array($user['page-flags'], [PAGE_NORMAL])) {
notification([ notification([
'type' => NOTIFY_INTRO, 'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'], 'notify_flags' => $user['notify-flags'],
'language' => $r[0]['language'], 'language' => $user['language'],
'to_name' => $r[0]['username'], 'to_name' => $user['username'],
'to_email' => $r[0]['email'], 'to_email' => $user['email'],
'uid' => $r[0]['uid'], 'uid' => $user['uid'],
'link' => System::baseUrl() . '/notifications/intro', 'link' => System::baseUrl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')), 'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
'source_link' => $contact_record['url'], '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", q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']), intval($importer['uid']),
dbesc($url) dbesc($url)
); );
} }
} }
} }

View file

@ -665,6 +665,8 @@ class GContact
{ {
$gcontact_id = 0; $gcontact_id = 0;
$doprobing = false; $doprobing = false;
$last_failure_str = '';
$last_contact_str = '';
if (in_array($contact["network"], [NETWORK_PHANTOM])) { if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);

View file

@ -251,9 +251,8 @@ class Item extends BaseObject
$arr['network'] = trim(defaults($arr, 'network', NETWORK_PHANTOM)); $arr['network'] = trim(defaults($arr, 'network', NETWORK_PHANTOM));
} }
if ($notify) { $guid_prefix = '';
$guid_prefix = ""; if ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
} elseif ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
$arr['guid'] = self::guidFromUri($arr['plink']); $arr['guid'] = self::guidFromUri($arr['plink']);
} elseif ((trim($arr['guid']) == "") && (trim($arr['uri']) != "")) { } elseif ((trim($arr['guid']) == "") && (trim($arr['uri']) != "")) {
$arr['guid'] = self::guidFromUri($arr['uri']); $arr['guid'] = self::guidFromUri($arr['uri']);
@ -521,6 +520,11 @@ class Item extends BaseObject
$arr['thr-parent'] = $arr['parent-uri']; $arr['thr-parent'] = $arr['parent-uri'];
$notify_type = '';
$allow_cid = '';
$allow_gid = '';
$deny_cid = '';
$deny_gid = '';
if ($arr['parent-uri'] === $arr['uri']) { if ($arr['parent-uri'] === $arr['uri']) {
$parent_id = 0; $parent_id = 0;
$parent_deleted = 0; $parent_deleted = 0;

View file

@ -67,6 +67,7 @@ class Mail
} }
} }
$convuri = '';
if (!$convid) { if (!$convid) {
// create a new conversation // create a new conversation
$recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3); $recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3);

View file

@ -91,6 +91,9 @@ class Photo
*/ */
public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false) public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
{ {
$thumb = '';
$micro = '';
$photo = dba::selectFirst( $photo = dba::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'] 'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
); );

View file

@ -565,8 +565,10 @@ class Profile
Cache::set($cachekey, $r, CACHE_HOUR); Cache::set($cachekey, $r, CACHE_HOUR);
} }
} }
$total = 0;
$classtoday = '';
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$total = 0;
$now = strtotime('now'); $now = strtotime('now');
$cids = []; $cids = [];

View file

@ -157,6 +157,8 @@ class User
*/ */
private static function getAuthenticationInfo($user_info) private static function getAuthenticationInfo($user_info)
{ {
$user = null;
if (is_object($user_info) || is_array($user_info)) { if (is_object($user_info) || is_array($user_info)) {
if (is_object($user_info)) { if (is_object($user_info)) {
$user = (array) $user_info; $user = (array) $user_info;

View file

@ -1542,29 +1542,31 @@ class Probe
return false; return false;
} }
if ($uid != 0) { if ($uid == 0) {
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid)); 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)) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
$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); if (DBM::is_result($x) && DBM::is_result($r)) {
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); $mailbox = Email::constructMailboxName($r[0]);
$password = '';
if (!count($msgs)) { openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
if (!$mbox) {
return false; 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); $phost = substr($uri, strpos($uri, '@') + 1);
$data = []; $data = [];

View file

@ -50,19 +50,11 @@ class ParseUrl
return false; return false;
} }
$r = q( $parsed_url = dba::selectFirst('parsed_url', ['content'],
"SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d", ['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
dbesc(normalise_link($url)),
intval(!$no_guessing),
intval($do_oembed)
); );
if (!empty($parsed_url['content'])) {
if ($r) { $data = unserialize($parsed_url['content']);
$data = $r[0]["content"];
}
if (!is_null($data)) {
$data = unserialize($data);
return $data; return $data;
} }

View file

@ -52,6 +52,7 @@ class XML
} }
} }
$element = null;
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if (!isset($element) && isset($xml)) { if (!isset($element) && isset($xml)) {
$element = $xml; $element = $xml;
@ -185,12 +186,13 @@ class XML
return(null); return(null);
} }
$xml_element_copy = '';
if (!is_string($xml_element) if (!is_string($xml_element)
&& !is_array($xml_element) && !is_array($xml_element)
&& (get_class($xml_element) == 'SimpleXMLElement') && (get_class($xml_element) == 'SimpleXMLElement')
) { ) {
$xml_element_copy = $xml_element; $xml_element_copy = $xml_element;
$xml_element = get_object_vars($xml_element); $xml_element = get_object_vars($xml_element);
} }
if (is_array($xml_element)) { if (is_array($xml_element)) {

View file

@ -34,11 +34,12 @@ class Delivery {
$relocate = false; $relocate = false;
$top_level = false; $top_level = false;
$recipients = []; $recipients = [];
$url_recipients = [];
$followup = false; $followup = false;
$normal_mode = true; $normal_mode = true;
$item = null;
$recipients[] = $contact_id; $recipients[] = $contact_id;
if ($cmd === 'mail') { if ($cmd === 'mail') {
@ -182,16 +183,14 @@ class Delivery {
} }
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0", // We don't deliver our items to blocked or pending contacts, and not to ourselves either
intval($contact_id) $contact = dba::selectFirst('contact', [],
['id' => $contact_id, 'blocked' => false, 'pending' => false, 'self' => false]
); );
if (!DBM::is_result($contact)) {
if (DBM::is_result($r)) {
$contact = $r[0];
}
if ($contact['self']) {
return; return;
} }
$deliver_status = 0; $deliver_status = 0;
// Transmit via Diaspora if not possible via Friendica // Transmit via Diaspora if not possible via Friendica
@ -207,7 +206,7 @@ class Delivery {
logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']); logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']);
if ($mail) { 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); $atom = DFRN::mail($item, $owner);
} elseif ($fsuggest) { } elseif ($fsuggest) {
$atom = DFRN::fsuggest($item, $owner); $atom = DFRN::fsuggest($item, $owner);

View file

@ -30,6 +30,8 @@ class DiscoverPoCo {
- check_profile: Update remote profile data - check_profile: Update remote profile data
*/ */
$search = "";
$mode = 0;
if ($command == "dirsearch") { if ($command == "dirsearch") {
$search = urldecode($param1); $search = urldecode($param1);
$mode = 1; $mode = 1;
@ -47,10 +49,7 @@ class DiscoverPoCo {
$mode = 7; $mode = 7;
} elseif ($command == "check_profile") { } elseif ($command == "check_profile") {
$mode = 8; $mode = 8;
} elseif ($command == '') { } elseif ($command !== "") {
$search = "";
$mode = 0;
} else {
logger("Unknown or missing parameter ".$command."\n"); logger("Unknown or missing parameter ".$command."\n");
return; return;
} }

View file

@ -67,6 +67,7 @@ class Notifier {
$url_recipients = []; $url_recipients = [];
$normal_mode = true; $normal_mode = true;
$recipients_relocate = [];
if ($cmd === 'mail') { if ($cmd === 'mail') {
$normal_mode = false; $normal_mode = false;
@ -178,6 +179,10 @@ class Notifier {
// fill this in with a single salmon slap if applicable // fill this in with a single salmon slap if applicable
$slap = ''; $slap = '';
$followup = false;
$recipients_followup = [];
$conversants = [];
$sql_extra = '';
if (! ($mail || $fsuggest || $relocate)) { if (! ($mail || $fsuggest || $relocate)) {
$slap = OStatus::salmon($target_item, $owner); $slap = OStatus::salmon($target_item, $owner);
@ -321,8 +326,6 @@ class Notifier {
Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id); Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id);
} }
$conversants = [];
foreach ($items as $item) { foreach ($items as $item) {
$recipients[] = $item['contact-id']; $recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id']; $conversants[] = $item['contact-id'];
@ -519,7 +522,7 @@ class Notifier {
// except for Diaspora batch jobs // except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to // 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']); logger('notifier: already delivered id=' . $rr['id']);
continue; continue;
} }

View file

@ -153,6 +153,7 @@ class OnePoll
} }
$importer = $r[0]; $importer = $r[0];
$url = '';
logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}"); logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");