From: Hypolite Petovan Date: Sun, 17 Dec 2017 20:31:37 +0000 (-0500) Subject: Fix undefined variable/wrong parameter count/unknown functions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2978b1eef0ef47809bbbce5e04e8336d6260255a;p=friendica.git Fix undefined variable/wrong parameter count/unknown functions --- diff --git a/src/Content/ForumManager.php b/src/Content/ForumManager.php index d800a0bd8b..3a564e328d 100644 --- a/src/Content/ForumManager.php +++ b/src/Content/ForumManager.php @@ -160,7 +160,7 @@ class ForumManager $contacts = self::getList($uid, $lastitem, false, false); $total_shown = 0; - + $forumlist = ''; foreach ($contacts as $contact) { $forumlist .= micropro($contact, false, 'forumlist-profile-advanced'); $total_shown ++; diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 4da097ce2a..e2673595c1 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -107,7 +107,7 @@ class Cache } // Frequently clear cache - self::clear($duration); + self::clear(); $r = dba::select('cache', array('v'), array('k' => $key), array('limit' => 1)); diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 7b9dba8963..9839f7147c 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -767,7 +767,7 @@ class NotificationsManager public function introNotifs($all = false, $start = 0, $limit = 80) { $ident = 'introductions'; - $total = $this->introTotal($seen); + $total = $this->introTotal($all); $notifs = array(); $sql_extra = ""; diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index bf84a4b8f7..4bc7193a0a 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -140,7 +140,7 @@ class PConfig // manage array value $dbvalue = (is_array($value) ? serialize($value) : $dbvalue); - dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true); + $ret = dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true); if ($ret) { self::$in_db[$uid][$family][$key] = true; diff --git a/src/Model/Group.php b/src/Model/Group.php index 410f78b156..a23b417cc9 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -139,8 +139,13 @@ class Group extends BaseObject return false; } + $group = dba::select('group', ['uid'], ['gid' => $gid], ['limit' => 1]); + if (!DBM::is_result($group)) { + return false; + } + // remove group from default posting lists - $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $uid], ['limit' => 1]); + $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']], ['limit' => 1]); if (DBM::is_result($user)) { $change = false; @@ -158,7 +163,7 @@ class Group extends BaseObject } if ($change) { - dba::update('user', $user, ['uid' => $uid]); + dba::update('user', $user, ['uid' => $group['uid']]); } } diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index e8f580c58a..27aa46d99f 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -44,7 +44,7 @@ class FKOAuthDataStore extends OAuthDataStore logger(__function__.":".$consumer_key); $s = dba::select('clients', array('client_id', 'pw', 'redirect_uri'), array('client_id' => $consumer_key)); - $r = dba::inArray($r); + $r = dba::inArray($s); if (DBM::is_result($r)) { return new \OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); @@ -119,7 +119,7 @@ class FKOAuthDataStore extends OAuthDataStore 'secret' => $sec, 'client_id' => $k, 'scope' => 'request', - 'expires' => UNIX_TIMESTAMP() + REQUEST_TOKEN_DURATION) + 'expires' => time() + REQUEST_TOKEN_DURATION) ); if (!$r) { @@ -160,7 +160,7 @@ class FKOAuthDataStore extends OAuthDataStore 'secret' => $sec, 'client_id' => $consumer->key, 'scope' => 'access', - 'expires' => UNIX_TIMESTAMP() + ACCESS_TOKEN_DURATION, + 'expires' => time() + ACCESS_TOKEN_DURATION, 'uid' => $uverifier) ); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index ee5e76cb4e..fd37a810c3 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2500,6 +2500,7 @@ class DFRN /// @todo Do we really need this check for HTML elements? (It was copied from the old function) if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) { + $base_url = get_app()->get_baseurl(); $item['body'] = reltoabs($item['body'], $base_url); $item['body'] = html2bb_video($item['body']); @@ -3014,7 +3015,7 @@ class DFRN // The account type is new since 3.5.1 if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) { - $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue); + $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()")->item(0)->nodeValue); if ($accounttype != $importer["contact-type"]) { dba::update('contact', array('contact-type' => $accounttype), array('id' => $importer["id"])); @@ -3023,7 +3024,7 @@ class DFRN // is it a public forum? Private forums aren't supported with this method // This is deprecated since 3.5.1 - $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue); + $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue); if ($forum != $importer["forum"]) { $condition = array('`forum` != ? AND `id` = ?', $forum, $importer["id"]); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 321df6d28c..a56b1fe877 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -665,7 +665,6 @@ class Diaspora } elseif (!in_array($fieldname, array("author_signature", "parent_author_signature", "target_author_signature"))) { if ($signed_data != "") { $signed_data .= ";"; - $signed_data_parent .= ";"; } $signed_data .= $entry; @@ -2311,16 +2310,16 @@ class Diaspora $A = "[url=".$self[0]["url"]."]".$self[0]["name"]."[/url]"; $B = "[url=".$contact["url"]."]".$contact["name"]."[/url]"; $BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]"; - $arr["body"] = sprintf(t("%1$s is now friends with %2$s"), $A, $B)."\n\n\n".$Bphoto; + $arr["body"] = sprintf(t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; $arr["object"] = self::constructNewFriendObject($contact); $arr["last-child"] = 1; - $arr["allow_cid"] = $user[0]["allow_cid"]; - $arr["allow_gid"] = $user[0]["allow_gid"]; - $arr["deny_cid"] = $user[0]["deny_cid"]; - $arr["deny_gid"] = $user[0]["deny_gid"]; + $arr["allow_cid"] = $self[0]["allow_cid"]; + $arr["allow_gid"] = $self[0]["allow_gid"]; + $arr["deny_cid"] = $self[0]["deny_cid"]; + $arr["deny_gid"] = $self[0]["deny_gid"]; $i = item_store($arr); if ($i) { @@ -3209,7 +3208,7 @@ class Diaspora $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid); } - logger("guid: ".$item["guid"]." result ".$return_code, LOGGER_DEBUG); + logger("guid: ".$guid." result ".$return_code, LOGGER_DEBUG); return $return_code; } diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 63706dcd68..b12b5c9329 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -127,7 +127,7 @@ class Feed { if ($value != "") { $author["author-nick"] = $value; } - $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue; + $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()')->item(0)->nodeValue; if ($value != "") { $author["author-location"] = $value; } @@ -299,9 +299,6 @@ class Feed { if ($creator != "") { $item["author-name"] = $creator; } - if ($pubDate != "") { - $item["edited"] = $item["created"] = $pubDate; - } $creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue; if ($creator != "") { diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 727cce4e1e..0fcf6f5743 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -816,7 +816,7 @@ class PortableContact return false; } - $server["site_name"] = $xpath->evaluate($element."//head/title/text()", $context)->item(0)->nodeValue; + $server["site_name"] = $xpath->evaluate($element."//head/title/text()")->item(0)->nodeValue; return $server; } diff --git a/src/Util/Lock.php b/src/Util/Lock.php index 69b906d03c..87590c295b 100644 --- a/src/Util/Lock.php +++ b/src/Util/Lock.php @@ -64,7 +64,7 @@ class Lock $file = $temp.'/'.$fn_name.'.sem'; if (!file_exists($file)) { - file_put_contents($file, $function); + file_put_contents($file, $fn_name); } return ftok($file, 'f'); diff --git a/src/Util/XML.php b/src/Util/XML.php index bfd1b8bf59..70af4cad53 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -292,11 +292,11 @@ class XML // Go through the tags. $repeated_tag_index = array(); // Multiple tags with same name will be turned into an array foreach ($xml_values as $data) { - unset($attributes, $value); // Remove existing values, or there will be trouble - - // This command will extract these variables into the foreach scope - // tag(string), type(string), level(int), attributes(array). - extract($data); // We could use the array by itself, but this cooler. + $tag = $data['tag']; + $type = $data['type']; + $level = $data['level']; + $attributes = isset($data['attributes']) ? $data['attributes'] : null; + $value = isset($data['value']) ? $data['value'] : null; $result = array(); $attributes_data = array(); diff --git a/src/Worker/CronHooks.php b/src/Worker/CronHooks.php index 22109931fe..fed65b2291 100644 --- a/src/Worker/CronHooks.php +++ b/src/Worker/CronHooks.php @@ -18,7 +18,7 @@ Class CronHooks { foreach ($a->hooks["cron"] as $single_hook) { if ($single_hook[1] == $hook) { logger("Calling cron hook '" . $hook . "'", LOGGER_DEBUG); - call_single_hook($a, $name, $single_hook, $data); + call_single_hook($a, $hook, $single_hook); } } return; diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 5a512e9b8e..e963d6d351 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -50,7 +50,7 @@ class Expire { foreach ($a->hooks["expire"] as $hook) { if ($hook[1] == $hook_name) { logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); - call_single_hook($a, $name, $hook, $data); + call_single_hook($a, $hook_name, $hook, $data); } } return; diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index eaf0058f19..fc819751bc 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -631,6 +631,7 @@ Class OnePoll dba::update('gcontact', array('last_failure' => $updated), array('nurl' => $contact['nurl'])); Contact::markForArchival($contact); } else { + $updated = datetime_convert(); dba::update('contact', array('last-update' => $updated), array('id' => $contact['id'])); } diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index 8b741b7861..179e37c077 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -55,7 +55,7 @@ class Queue */ $r = q("SELECT `id` FROM `queue` WHERE ((`created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE) OR (`last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR)) ORDER BY `cid`, `created`"); - call_hooks('queue_predeliver', $a, $r); + call_hooks('queue_predeliver', $r); if (DBM::is_result($r)) { foreach ($r as $q_item) { @@ -166,7 +166,7 @@ class Queue default: $params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false); - call_hooks('queue_deliver', $a, $params); + call_hooks('queue_deliver', $params); if ($params['result']) { remove_queue_item($q_item['id']);