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;
break;
case CACHE_MINUTE:
default:
$seconds = 60;
break;
}

View file

@ -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(

View file

@ -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;

View file

@ -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_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)
);
}
}
}

View file

@ -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);

View file

@ -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;

View file

@ -67,6 +67,7 @@ class Mail
}
}
$convuri = '';
if (!$convid) {
// create a new conversation
$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)
{
$thumb = '';
$micro = '';
$photo = dba::selectFirst(
'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);
}
}
if (DBM::is_result($r)) {
$total = 0;
$classtoday = '';
if (DBM::is_result($r)) {
$now = strtotime('now');
$cids = [];

View file

@ -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;

View file

@ -1542,7 +1542,10 @@ class Probe
return false;
}
if ($uid != 0) {
if ($uid == 0) {
return false;
}
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
@ -1552,7 +1555,7 @@ class Probe
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
if (!mbox) {
if (!$mbox) {
return false;
}
}
@ -1563,7 +1566,6 @@ class Probe
if (!count($msgs)) {
return false;
}
}
$phost = substr($uri, strpos($uri, '@') + 1);

View file

@ -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;
}

View file

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

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

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