From 10b72b0e9eb0aa2ef1f2c612464ffcbbe4cc02ce Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:24:57 -0500 Subject: [PATCH 01/14] PHPStan: Fix missing requires/namespaces --- src/App.php | 3 +++ src/Content/ForumManager.php | 2 ++ src/Core/Cache.php | 4 +++- src/Core/Config.php | 2 ++ src/Core/NotificationsManager.php | 3 ++- src/Core/PConfig.php | 2 ++ src/Core/Worker.php | 2 ++ src/Database/DBM.php | 2 ++ src/Database/DBStructure.php | 4 +++- src/Model/Contact.php | 1 + src/Model/GContact.php | 1 + src/Model/Group.php | 1 + src/Model/Photo.php | 2 ++ src/Model/User.php | 3 ++- src/Network/FKOAuthDataStore.php | 12 +++++++----- src/Network/Probe.php | 3 ++- src/Object/Post.php | 1 + src/ParseUrl.php | 5 +++-- src/Protocol/DFRN.php | 15 ++++++++------- src/Protocol/Diaspora.php | 1 + src/Protocol/Feed.php | 9 +++++---- src/Protocol/OStatus.php | 13 +++++++------ src/Protocol/PortableContact.php | 7 ++++--- src/Util/ExAuth.php | 5 +++-- src/Util/Lock.php | 2 ++ src/Util/Pidfile.php | 2 +- src/Util/XML.php | 4 ++-- src/Worker/Cron.php | 2 ++ src/Worker/CronJobs.php | 4 ++++ src/Worker/DBClean.php | 2 ++ src/Worker/Expire.php | 2 ++ src/Worker/Notifier.php | 1 + src/Worker/OnePoll.php | 1 + src/Worker/Queue.php | 1 + src/Worker/RemoveContact.php | 2 ++ 35 files changed, 89 insertions(+), 37 deletions(-) diff --git a/src/App.php b/src/App.php index 3e34d3c5a9..adea01a037 100644 --- a/src/App.php +++ b/src/App.php @@ -14,6 +14,9 @@ use Detection\MobileDetect; use Exception; +require_once 'boot.php'; +require_once 'include/dba.php'; + /** * * class: App diff --git a/src/Content/ForumManager.php b/src/Content/ForumManager.php index d619db42b2..d800a0bd8b 100644 --- a/src/Content/ForumManager.php +++ b/src/Content/ForumManager.php @@ -11,6 +11,8 @@ use Friendica\Core\System; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief This class handles methods related to the forum functionality */ diff --git a/src/Core/Cache.php b/src/Core/Cache.php index eb58811e2c..4da097ce2a 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -9,6 +9,8 @@ use Friendica\Core\PConfig; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief Class for storing data for a short time */ @@ -32,7 +34,7 @@ class Cache $memcache_host = Config::get('system', 'memcache_host', '127.0.0.1'); $memcache_port = Config::get('system', 'memcache_port', 11211); - $memcache = new Memcache; + $memcache = new \Memcache; if (!$memcache->connect($memcache_host, $memcache_port)) { return false; diff --git a/src/Core/Config.php b/src/Core/Config.php index d3daece159..2515116a9b 100644 --- a/src/Core/Config.php +++ b/src/Core/Config.php @@ -11,6 +11,8 @@ namespace Friendica\Core; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief Arbitrary sytem configuration storage * diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 9adac10c92..7b9dba8963 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -6,11 +6,12 @@ */ namespace Friendica\Core; -use Friendica\Core\Pconfig; +use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; +require_once 'include/dba.php'; require_once 'include/html2plain.php'; require_once 'include/datetime.php'; require_once 'include/bbcode.php'; diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index 3467032fa2..bf84a4b8f7 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -7,6 +7,8 @@ namespace Friendica\Core; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @file include/Core/PConfig.php * @brief contains the class with methods for the management diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 2e7bb483e8..760b40b1d3 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -13,6 +13,8 @@ use Friendica\Util\Lock; use dba; +require_once 'include/dba.php'; + /** * @file src/Core/Worker.php * diff --git a/src/Database/DBM.php b/src/Database/DBM.php index 7b52c0a552..e59249e1b9 100644 --- a/src/Database/DBM.php +++ b/src/Database/DBM.php @@ -6,6 +6,8 @@ namespace Friendica\Database; use dba; +require_once 'include/dba.php'; + /** * @brief This class contain functions for the database management * diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 7a6c3eaa70..c5bd3e99bc 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -9,6 +9,8 @@ use Friendica\Database\DBM; use dba; require_once "boot.php"; +require_once 'include/dba.php'; +require_once 'include/enotify.php'; require_once "include/text.php"; /** @@ -565,7 +567,7 @@ class DBStructure { private static function createIndex($indexname, $fieldnames, $method = "ADD") { $method = strtoupper(trim($method)); if ($method!="" && $method!="ADD") { - throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); + throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); } if ($fieldnames[0] == "UNIQUE") { diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 2203b62162..aec417a65d 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -20,6 +20,7 @@ use Friendica\Protocol\Salmon; use dba; require_once 'boot.php'; +require_once 'include/dba.php'; require_once 'include/text.php'; /** diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 1b846b3171..5622124481 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -17,6 +17,7 @@ use dba; use Exception; require_once 'include/datetime.php'; +require_once 'include/dba.php'; require_once 'include/network.php'; require_once 'include/html2bbcode.php'; diff --git a/src/Model/Group.php b/src/Model/Group.php index 9251bc49de..209c78798b 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -11,6 +11,7 @@ use Friendica\Database\DBM; use dba; require_once 'boot.php'; +require_once 'include/dba.php'; require_once 'include/text.php'; /** diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 229f221077..0fbeb66cbb 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -12,7 +12,9 @@ use Friendica\Database\DBM; use Friendica\Object\Image; use dba; +require_once 'include/dba.php'; require_once "include/photos.php"; + /** * Class to handle photo dabatase table */ diff --git a/src/Model/User.php b/src/Model/User.php index d09d670a4b..9762727aca 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -21,6 +21,7 @@ use Exception; require_once 'boot.php'; require_once 'include/crypto.php'; +require_once 'include/dba.php'; require_once 'include/enotify.php'; require_once 'include/network.php'; require_once 'library/openid.php'; @@ -186,7 +187,7 @@ class User $_SESSION['register'] = 1; $_SESSION['openid'] = $openid_url; - $openid = new LightOpenID; + $openid = new \LightOpenID; $openid->identity = $openid_url; $openid->returnUrl = System::baseUrl() . '/openid'; $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson'); diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index d7fa145189..e8f580c58a 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -17,6 +17,8 @@ use OAuthDataStore; define('REQUEST_TOKEN_DURATION', 300); define('ACCESS_TOKEN_DURATION', 31536000); +require_once 'include/dba.php'; + require_once "library/OAuth1.php"; require_once "library/oauth2-php/lib/OAuth2.inc"; @@ -45,7 +47,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::inArray($r); if (DBM::is_result($r)) { - return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); + return new \OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); } return null; @@ -65,7 +67,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::inArray($s); if (DBM::is_result($r)) { - $ot=new OAuthToken($r[0]['id'], $r[0]['secret']); + $ot = new \OAuthToken($r[0]['id'], $r[0]['secret']); $ot->scope = $r[0]['scope']; $ot->expires = $r[0]['expires']; $ot->uid = $r[0]['uid']; @@ -87,7 +89,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]); if (DBM::is_result($r)) { - return new OAuthToken($r['id'], $r['secret']); + return new \OAuthToken($r['id'], $r['secret']); } return null; @@ -124,7 +126,7 @@ class FKOAuthDataStore extends OAuthDataStore return null; } - return new OAuthToken($key, $sec); + return new \OAuthToken($key, $sec); } /** @@ -163,7 +165,7 @@ class FKOAuthDataStore extends OAuthDataStore ); if ($r) { - $ret = new OAuthToken($key, $sec); + $ret = new \OAuthToken($key, $sec); } } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 7955961838..56abbb7fdc 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -20,9 +20,10 @@ use Friendica\Protocol\Feed; use Friendica\Util\XML; use dba; -use DomXPath; +use DOMXPath; use DOMDocument; +require_once 'include/dba.php'; require_once 'include/network.php'; require_once "include/crypto.php"; diff --git a/src/Object/Post.php b/src/Object/Post.php index 902435b513..f331538873 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -11,6 +11,7 @@ use Friendica\Database\DBM; use Friendica\Model\Contact; use dba; +require_once 'include/dba.php'; require_once 'include/text.php'; require_once 'boot.php'; require_once 'include/conversation.php'; diff --git a/src/ParseUrl.php b/src/ParseUrl.php index 35557067d7..c2c01b8aeb 100644 --- a/src/ParseUrl.php +++ b/src/ParseUrl.php @@ -10,9 +10,10 @@ use Friendica\Object\Image; use Friendica\Util\XML; use dba; -use DomXPath; +use DOMXPath; use DOMDocument; +require_once 'include/dba.php'; require_once "include/network.php"; require_once "include/oembed.php"; @@ -215,7 +216,7 @@ class ParseUrl XML::deleteNode($doc, "ol"); XML::deleteNode($doc, "ul"); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//meta[@content]"); foreach ($list as $node) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 62ada9620a..e9df296258 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -8,7 +8,6 @@ */ namespace Friendica\Protocol; -use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Core\Worker; @@ -22,8 +21,10 @@ use Friendica\Util\XML; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; +require_once 'boot.php'; +require_once 'include/dba.php'; require_once "include/enotify.php"; require_once "include/threads.php"; require_once "include/items.php"; @@ -1298,7 +1299,7 @@ class DFRN case 2: // RINO 2 based on php-encryption try { - $key = \Crypto::createNewRandomKey(); + $key = \Crypto::CreateNewRandomKey(); } catch (\CryptoTestFailedException $ex) { logger('Cannot safely create a key'); return -4; @@ -1307,7 +1308,7 @@ class DFRN return -5; } try { - $data = \Crypto::encrypt($postvars['data'], $key); + $data = \Crypto::Encrypt($postvars['data'], $key); } catch (\CryptoTestFailedException $ex) { logger('Cannot safely perform encryption'); return -6; @@ -2505,13 +2506,13 @@ class DFRN $item['body'] = oembed_html2bbcode($item['body']); - $config = HTMLPurifier_Config::createDefault(); + $config = \HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); // we shouldn't need a whitelist, because the bbcode converter // will strip out any unsupported tags. - $purifier = new HTMLPurifier($config); + $purifier = new \HTMLPurifier($config); $item['body'] = $purifier->purify($item['body']); $item['body'] = @html2bbcode($item['body']); @@ -2977,7 +2978,7 @@ class DFRN $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace("atom", NAMESPACE_ATOM1); $xpath->registerNamespace("thr", NAMESPACE_THREAD); $xpath->registerNamespace("at", NAMESPACE_TOMB); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 5c6d1a2c06..9090e4b6b2 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -27,6 +27,7 @@ use Friendica\Util\XML; use dba; use SimpleXMLElement; +require_once 'include/dba.php'; require_once 'include/items.php'; require_once 'include/bb2diaspora.php'; require_once 'include/datetime.php'; diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index c33852a7d5..629c2bfdd0 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -10,10 +10,11 @@ use Friendica\Database\DBM; use Friendica\Core\System; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; -require_once("include/html2bbcode.php"); -require_once("include/items.php"); +require_once 'include/dba.php'; +require_once 'include/html2bbcode.php'; +require_once 'include/items.php'; /** * @brief This class contain functions to import feeds @@ -55,7 +56,7 @@ class Feed { $doc = new DOMDocument(); @$doc->loadXML(trim($xml)); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/"); $xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/"); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 2a021c89e9..cadc9a37ea 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -17,8 +17,9 @@ use Friendica\Util\Lock; use Friendica\Util\XML; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; +require_once 'include/dba.php'; require_once 'include/threads.php'; require_once 'include/html2bbcode.php'; require_once 'include/bbcode.php'; @@ -251,7 +252,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('georss', NAMESPACE_GEORSS); @@ -329,7 +330,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('georss', NAMESPACE_GEORSS); @@ -739,7 +740,7 @@ class OStatus if (!@$doc->loadHTML($conversation_data['body'])) { return; } - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $links = $xpath->query('//link'); if ($links) { @@ -779,7 +780,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS); @@ -929,7 +930,7 @@ class OStatus if (!@$doc->loadHTML($related_data['body'])) { return; } - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $atom_file = ''; diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 2b37a99624..727cce4e1e 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -17,9 +17,10 @@ use Friendica\Model\Profile; use Friendica\Network\Probe; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; use Exception; +require_once 'include/dba.php'; require_once 'include/datetime.php'; require_once 'include/network.php'; require_once 'include/html2bbcode.php'; @@ -512,7 +513,7 @@ class PortableContact $doc = new DOMDocument(); @$doc->loadXML($feedret["body"]); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom"); $entries = $xpath->query('/atom:feed/atom:entry'); @@ -768,7 +769,7 @@ class PortableContact $doc = new DOMDocument(); @$doc->loadHTML($body); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//meta[@name]"); diff --git a/src/Util/ExAuth.php b/src/Util/ExAuth.php index f83901e989..054b87aad4 100644 --- a/src/Util/ExAuth.php +++ b/src/Util/ExAuth.php @@ -40,6 +40,7 @@ use Friendica\Database\DBM; use Friendica\Model\User; use dba; +require_once 'include/dba.php'; require_once 'include/dba.php'; class ExAuth @@ -313,7 +314,7 @@ class ExAuth } $file = $lockpath . DIRECTORY_SEPARATOR . $host; - if (Pidfile::isRunningProcess($file)) { + if (PidFile::isRunningProcess($file)) { if (PidFile::killProcess($file)) { $this->writeLog(LOG_INFO, 'Old process was successfully killed'); } else { @@ -323,7 +324,7 @@ class ExAuth } // Now it is safe to create the pid file - Pidfile::create($file); + PidFile::create($file); } /** diff --git a/src/Util/Lock.php b/src/Util/Lock.php index 9c44984459..69b906d03c 100644 --- a/src/Util/Lock.php +++ b/src/Util/Lock.php @@ -14,6 +14,8 @@ use Friendica\Database\DBM; use Memcache; use dba; +require_once 'include/dba.php'; + /** * @brief This class contain Functions for preventing parallel execution of functions */ diff --git a/src/Util/Pidfile.php b/src/Util/Pidfile.php index 9d12b0bd25..00a67d872e 100644 --- a/src/Util/Pidfile.php +++ b/src/Util/Pidfile.php @@ -7,7 +7,7 @@ namespace Friendica\Util; /** * @brief Pidfile class */ -class Pidfile +class PidFile { /** * @brief Read the pid from a given pid file diff --git a/src/Util/XML.php b/src/Util/XML.php index a3cf758da5..e5e649a07c 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -4,7 +4,7 @@ */ namespace Friendica\Util; -use DomXPath; +use DOMXPath; use SimpleXMLElement; /** @@ -407,7 +407,7 @@ class XML */ public static function deleteNode(&$doc, $node) { - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//".$node); foreach ($list as $child) { $child->parentNode->removeChild($child); diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index db0d518cc3..6afa616016 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -9,6 +9,8 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + Class Cron { public static function execute($parameter = '', $generation = 0) { global $a; diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index b59f096d7d..93f1e3a03a 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -16,6 +16,10 @@ use Friendica\Network\Probe; use Friendica\Protocol\PortableContact; use dba; +require_once 'include/dba.php'; +require_once 'include/post_update.php'; +require_once 'mod/nodeinfo.php'; + class CronJobs { public static function execute($command = '') diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index 45a080400e..8d1228f018 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -10,6 +10,8 @@ use Friendica\Core\Config; use Friendica\Core\Worker; use dba; +require_once 'include/dba.php'; + class DBClean { public static function execute($stage = 0) { diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 61326fa88e..5a512e9b8e 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -11,6 +11,8 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + class Expire { public static function execute($param = '', $hook_name = '') { global $a; diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 7494780444..e3eb6810a3 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -15,6 +15,7 @@ use Friendica\Protocol\OStatus; use Friendica\Protocol\Salmon; use dba; +require_once 'include/dba.php'; require_once 'include/queue_fn.php'; require_once 'include/html2plain.php'; require_once 'include/datetime.php'; diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 9024d0d4c9..eaf0058f19 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -12,6 +12,7 @@ use Friendica\Protocol\Email; use Friendica\Protocol\PortableContact; use dba; +require_once 'include/dba.php'; require_once 'include/follow.php'; Class OnePoll diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index cb00addc94..8b741b7861 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -14,6 +14,7 @@ use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; use dba; +require_once 'include/dba.php'; require_once 'include/queue_fn.php'; require_once 'include/datetime.php'; require_once 'include/items.php'; diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 811b0295fb..4098d66bc5 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -8,6 +8,8 @@ namespace Friendica\Worker; use Friendica\Core\Config; use dba; +require_once 'include/dba.php'; + class RemoveContact { public static function execute($id) { From 916236ce2fe2c0e9e48d000c6d665f96fecf00a9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:27:50 -0500 Subject: [PATCH 02/14] Fix docblocks types --- boot.php | 2 ++ include/text.php | 2 +- src/App.php | 2 +- src/Model/Contact.php | 2 +- src/Model/GContact.php | 10 +++++----- src/Model/Group.php | 8 ++++---- src/Object/Image.php | 2 +- src/ParseUrl.php | 14 +++++++------- src/Protocol/DFRN.php | 10 +++++----- src/Protocol/Diaspora.php | 6 ++++-- src/Util/XML.php | 2 +- src/Worker/DiscoverPoCo.php | 2 +- 12 files changed, 33 insertions(+), 29 deletions(-) diff --git a/boot.php b/boot.php index 695f9e85c5..00058727f5 100644 --- a/boot.php +++ b/boot.php @@ -524,6 +524,8 @@ function startup() * @brief Retrieve the App structure * * Useful in functions which require it but don't get it passed to them + * + * @return App */ function get_app() { diff --git a/include/text.php b/include/text.php index 5cc573697d..cbba8d0c5b 100644 --- a/include/text.php +++ b/include/text.php @@ -1701,7 +1701,7 @@ function array_xmlify($val){ /** - * transorm link href and img src from relative to absolute + * transform link href and img src from relative to absolute * * @param string $text * @param string $base base url diff --git a/src/App.php b/src/App.php index adea01a037..b16786140a 100644 --- a/src/App.php +++ b/src/App.php @@ -619,7 +619,7 @@ class App { * If $name is not defined, return engine defined by theme, * or default * - * @param strin $name Template engine name + * @param string $name Template engine name * @return object Template Engine instance */ function template_engine($name = '') { diff --git a/src/Model/Contact.php b/src/Model/Contact.php index aec417a65d..1b15f1c76d 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -197,7 +197,7 @@ class Contact extends BaseObject * up or some other transient event and that there's a possibility we could recover from it. * * @param array $contact contact to mark for archival - * @return type + * @return null */ public static function markForArchival(array $contact) { diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 5622124481..6c13c03b1e 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -636,7 +636,7 @@ class GContact /** * @brief Replace alternate OStatus user format with the primary one * - * @param arr $contact contact array (called by reference) + * @param array $contact contact array (called by reference) * @return void */ public static function fixAlternateContactAddress(&$contact) @@ -656,7 +656,7 @@ class GContact /** * @brief Fetch the gcontact id, add an entry if not existed * - * @param arr $contact contact array + * @param array $contact contact array * * @return bool|int Returns false if not found, integer if contact was found */ @@ -747,7 +747,7 @@ class GContact /** * @brief Updates the gcontact table from a given array * - * @param arr $contact contact array + * @param array $contact contact array * * @return bool|int Returns false if not found, integer if contact was found */ @@ -908,7 +908,7 @@ class GContact /** * @brief Updates the gcontact entry from probe * - * @param str $url profile link + * @param string $url profile link * @return void */ public static function updateFromProbe($url) @@ -974,7 +974,7 @@ class GContact * * If the "Statistics" plugin is enabled (See http://gstools.org/ for details) we query user data with this. * - * @param str $server Server address + * @param string $server Server address * @return void */ public static function fetchGsUsers($server) diff --git a/src/Model/Group.php b/src/Model/Group.php index 209c78798b..410f78b156 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -131,7 +131,7 @@ class Group extends BaseObject /** * @brief Mark a group as deleted * - * @param type $gid + * @param int $gid * @return boolean */ public static function remove($gid) { @@ -176,9 +176,9 @@ class Group extends BaseObject * * @deprecated Use Group::remove instead * - * @param type $uid - * @param type $name - * @return type + * @param int $uid + * @param string $name + * @return bool */ public static function removeByName($uid, $name) { $return = false; diff --git a/src/Object/Image.php b/src/Object/Image.php index b39945ede6..f979e49438 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -111,7 +111,7 @@ class Image /** * @brief Maps Mime types to Imagick formats - * @return arr With with image formats (mime type as key) + * @return array With with image formats (mime type as key) */ public static function getFormatsMap() { diff --git a/src/ParseUrl.php b/src/ParseUrl.php index c2c01b8aeb..9e46281ec9 100644 --- a/src/ParseUrl.php +++ b/src/ParseUrl.php @@ -25,10 +25,10 @@ class ParseUrl /** * @brief Search for chached embeddable data of an url otherwise fetch it * - * @param type $url The url of the page which should be scraped - * @param type $no_guessing If true the parse doens't search for + * @param string $url The url of the page which should be scraped + * @param bool $no_guessing If true the parse doens't search for * preview pictures - * @param type $do_oembed The false option is used by the function fetch_oembed() + * @param bool $do_oembed The false option is used by the function fetch_oembed() * to avoid endless loops * * @return array which contains needed data for embedding @@ -89,12 +89,12 @@ class ParseUrl * like \Awesome Title\ or * \ * - * @param type $url The url of the page which should be scraped - * @param type $no_guessing If true the parse doens't search for + * @param string $url The url of the page which should be scraped + * @param bool $no_guessing If true the parse doens't search for * preview pictures - * @param type $do_oembed The false option is used by the function fetch_oembed() + * @param bool $do_oembed The false option is used by the function fetch_oembed() * to avoid endless loops - * @param type $count Internal counter to avoid endless loops + * @param int $count Internal counter to avoid endless loops * * @return array which contains needed data for embedding * string 'url' => The url of the parsed page diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index e9df296258..ee5e76cb4e 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1443,7 +1443,7 @@ class DFRN * @param bool $onlyfetch Should the data only be fetched or should it update the contact record as well * @param string $xml optional, default empty * - * @return Returns an array with relevant data of the author + * @return array Relevant data of the author * @todo Find good type-hints for all parameter */ private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "") @@ -1692,7 +1692,7 @@ class DFRN * * @param object $xpath XPath object * @param object $activity Activity object - * @param text $element element name + * @param string $element element name * * @return string XML string * @todo Find good type-hints for all parameter @@ -2963,9 +2963,9 @@ class DFRN /** * @brief Imports a DFRN message * - * @param text $xml The DFRN message - * @param array $importer Record of the importer user mixed with contact of the content - * @param bool $sort_by_date Is used when feeds are polled + * @param string $xml The DFRN message + * @param array $importer Record of the importer user mixed with contact of the content + * @param bool $sort_by_date Is used when feeds are polled * @return integer Import status * @todo set proper type-hints */ diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 9090e4b6b2..5ae63bd7a8 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -928,10 +928,12 @@ class Diaspora /** * @brief Get a contact id for a given handle * + * @todo Move to Friendica\Model\Contact + * * @param int $uid The user id * @param string $handle The handle in the format user@domain.tld * - * @return The contact id + * @return int Contact id */ private static function contactByHandle($uid, $handle) { @@ -1113,7 +1115,7 @@ class Diaspora * @param string $body The item body to replace links from * @param string $author_link The author link for missing local contact fallback * - * @return the replaced string + * @return string the replaced string */ public static function replacePeopleGuid($body, $author_link) { diff --git a/src/Util/XML.php b/src/Util/XML.php index e5e649a07c..bfd1b8bf59 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -176,7 +176,7 @@ class XML * @param integer $recursion_depth recursion counter for internal use - default 0 * internal use, recursion counter * - * @return array | sring The array from the xml element or the string + * @return array | string The array from the xml element or the string */ public static function elementToArray($xml_element, &$recursion_depth = 0) { diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php index b3c03e9050..b7b7f0a31c 100644 --- a/src/Worker/DiscoverPoCo.php +++ b/src/Worker/DiscoverPoCo.php @@ -268,7 +268,7 @@ class DiscoverPoCo { /** * @brief Search for GNU Social user with gstools.org * - * @param str $search User name + * @param string $search User name */ private static function gsSearchUser($search) { From 4b5894817e459cdb08b5774e8f4ab97dbddd677d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:29:16 -0500 Subject: [PATCH 03/14] Fix class methods staticity/return value --- src/App.php | 6 ++---- src/Protocol/Diaspora.php | 4 ++-- src/Protocol/Feed.php | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/App.php b/src/App.php index b16786140a..95a2e99d69 100644 --- a/src/App.php +++ b/src/App.php @@ -312,10 +312,8 @@ class App { * * @return string */ - public static function get_basepath() { - if (isset($this)) { - $basepath = $this->basepath; - } + public function get_basepath() { + $basepath = $this->basepath; if (! $basepath) { $basepath = Config::get('system', 'basepath'); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 5ae63bd7a8..321df6d28c 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1094,7 +1094,7 @@ class Diaspora preg_replace_callback( $expression, function ($match) use ($item) { - return self::fetchGuidSub($match, $item); + self::fetchGuidSub($match, $item); }, $item["body"] ); @@ -1102,7 +1102,7 @@ class Diaspora preg_replace_callback( "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", function ($match) use ($item) { - return self::fetchGuidSub($match, $item); + self::fetchGuidSub($match, $item); }, $item["body"] ); diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 629c2bfdd0..63706dcd68 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -32,7 +32,7 @@ class Feed { * * @return array In simulation mode it returns the header and the first item */ - function import($xml, $importer, &$contact, &$hub, $simulate = false) { + public static function import($xml, $importer, &$contact, &$hub, $simulate = false) { $a = get_app(); From 2978b1eef0ef47809bbbce5e04e8336d6260255a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:31:37 -0500 Subject: [PATCH 04/14] Fix undefined variable/wrong parameter count/unknown functions --- src/Content/ForumManager.php | 2 +- src/Core/Cache.php | 2 +- src/Core/NotificationsManager.php | 2 +- src/Core/PConfig.php | 2 +- src/Model/Group.php | 9 +++++++-- src/Network/FKOAuthDataStore.php | 6 +++--- src/Protocol/DFRN.php | 5 +++-- src/Protocol/Diaspora.php | 13 ++++++------- src/Protocol/Feed.php | 5 +---- src/Protocol/PortableContact.php | 2 +- src/Util/Lock.php | 2 +- src/Util/XML.php | 10 +++++----- src/Worker/CronHooks.php | 2 +- src/Worker/Expire.php | 2 +- src/Worker/OnePoll.php | 1 + src/Worker/Queue.php | 4 ++-- 16 files changed, 36 insertions(+), 33 deletions(-) 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']); From 910d3f7b5f16cda15074107073a489e4426c369a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:34:29 -0500 Subject: [PATCH 05/14] Formatting FKOauthDataStore --- src/Network/FKOAuthDataStore.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index 27aa46d99f..424b6391ee 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -1,10 +1,12 @@ * */ + namespace Friendica\Network; use Friendica\App; @@ -41,8 +43,8 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_consumer($consumer_key) { - logger(__function__.":".$consumer_key); - + logger(__function__ . ":" . $consumer_key); + $s = dba::select('clients', array('client_id', 'pw', 'redirect_uri'), array('client_id' => $consumer_key)); $r = dba::inArray($s); @@ -61,8 +63,8 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_token($consumer, $token_type, $token) { - logger(__function__.":".$consumer.", ". $token_type.", ".$token); - + logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token); + $s = dba::select('tokens', array('id', 'secret', 'scope', 'expires', 'uid'), array('client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token)); $r = dba::inArray($s); @@ -87,7 +89,7 @@ class FKOAuthDataStore extends OAuthDataStore public function lookup_nonce($consumer, $token, $nonce, $timestamp) { $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]); - + if (DBM::is_result($r)) { return new \OAuthToken($r['id'], $r['secret']); } @@ -102,7 +104,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_request_token($consumer, $callback = null) { - logger(__function__.":".$consumer.", ". $callback); + logger(__function__ . ":" . $consumer . ", " . $callback); $key = self::genToken(); $sec = self::genToken(); @@ -137,7 +139,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_access_token($token, $consumer, $verifier = null) { - logger(__function__.":".$token.", ". $consumer.", ". $verifier); + logger(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier); // return a new access token attached to this consumer // for the user associated with this token if the request token @@ -148,9 +150,9 @@ class FKOAuthDataStore extends OAuthDataStore // get user for this verifier $uverifier = Config::get("oauth", $verifier); - logger(__function__.":".$verifier.",".$uverifier); + logger(__function__ . ":" . $verifier . "," . $uverifier); - if (is_null($verifier) || ($uverifier!==false)) { + if (is_null($verifier) || ($uverifier !== false)) { $key = self::genToken(); $sec = self::genToken(); $r = dba::insert( @@ -169,10 +171,8 @@ class FKOAuthDataStore extends OAuthDataStore } } - dba::delete('tokens', array('id' => $token->key)); - if (!is_null($ret) && !is_null($uverifier)) { Config::delete("oauth", $verifier); } From a6a2c578f921d21588187c89f84104ef12d04b6a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:35:07 -0500 Subject: [PATCH 06/14] Add new common Image::scale() method - Fix undefined variable $type --- src/Object/Image.php | 125 ++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 72 deletions(-) diff --git a/src/Object/Image.php b/src/Object/Image.php index f979e49438..7cbc2432d9 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -142,7 +142,7 @@ class Image * Setup the image to the format it will be saved to */ $map = self::getFormatsMap(); - $format = $map[$type]; + $format = $map[$this->type]; $this->image->setFormat($format); // Always coalesce, if it is not a multi-frame image it won't hurt anyway @@ -338,42 +338,7 @@ class Image } } - - if ($this->isImagick()) { - /* - * If it is not animated, there will be only one iteration here, - * so don't bother checking - */ - // Don't forget to go back to the first frame - $this->image->setFirstIterator(); - do { - // FIXME - implement horizantal bias for scaling as in followin GD functions - // to allow very tall images to be constrained only horizontally. - - $this->image->scaleImage($dest_width, $dest_height); - } while ($this->image->nextImage()); - - // These may not be necessary any more - $this->width = $this->image->getImageWidth(); - $this->height = $this->image->getImageHeight(); - - return; - } - - - $dest = imagecreatetruecolor($dest_width, $dest_height); - imagealphablending($dest, false); - imagesavealpha($dest, true); - if ($this->type=='image/png') { - imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha - } - imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); - if ($this->image) { - imagedestroy($this->image); - } - $this->image = $dest; - $this->width = imagesx($this->image); - $this->height = imagesy($this->image); + return $this->scale($dest_width, $dest_height); } /** @@ -562,23 +527,7 @@ class Image } } - if ($this->isImagick()) { - return $this->scaleDown($dest_width, $dest_height); - } - - $dest = imagecreatetruecolor($dest_width, $dest_height); - imagealphablending($dest, false); - imagesavealpha($dest, true); - if ($this->type=='image/png') { - imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha - } - imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); - if ($this->image) { - imagedestroy($this->image); - } - $this->image = $dest; - $this->width = imagesx($this->image); - $this->height = imagesy($this->image); + return $this->scale($dest_width, $dest_height); } /** @@ -591,27 +540,59 @@ class Image return false; } - if ($this->isImagick()) { - $this->image->setFirstIterator(); - do { - $this->image->scaleImage($dim, $dim); - } while ($this->image->nextImage()); - return; + return $this->scale($dim, $dim); + } + + /** + * @brief Scale image to target dimensions + * + * @param int $dest_width + * @param int $dest_height + * @return boolean + */ + private function scale($dest_width, $dest_height) + { + if (!$this->isValid()) { + return false; } - $dest = imagecreatetruecolor($dim, $dim); - imagealphablending($dest, false); - imagesavealpha($dest, true); - if ($this->type=='image/png') { - imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha + if ($this->isImagick()) { + /* + * If it is not animated, there will be only one iteration here, + * so don't bother checking + */ + // Don't forget to go back to the first frame + $this->image->setFirstIterator(); + do { + // FIXME - implement horizontal bias for scaling as in following GD functions + // to allow very tall images to be constrained only horizontally. + $this->image->scaleImage($dest_width, $dest_height); + } while ($this->image->nextImage()); + + // These may not be necessary anymore + $this->width = $this->image->getImageWidth(); + $this->height = $this->image->getImageHeight(); + } else { + $dest = imagecreatetruecolor($dest_width, $dest_height); + imagealphablending($dest, false); + imagesavealpha($dest, true); + + if ($this->type=='image/png') { + imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha + } + + imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $this->width, $this->height); + + if ($this->image) { + imagedestroy($this->image); + } + + $this->image = $dest; + $this->width = imagesx($this->image); + $this->height = imagesy($this->image); } - imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height); - if ($this->image) { - imagedestroy($this->image); - } - $this->image = $dest; - $this->width = imagesx($this->image); - $this->height = imagesy($this->image); + + return true; } /** From 5926cd534aac8bf481c49267be3cf9e9636a8a41 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:35:38 -0500 Subject: [PATCH 07/14] Add FIXME for unrecoverable missing variables --- src/Protocol/Diaspora.php | 1 + src/Protocol/OStatus.php | 1 + src/Protocol/PortableContact.php | 1 + src/Worker/Directory.php | 1 + 4 files changed, 4 insertions(+) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index a56b1fe877..466104c404 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4067,6 +4067,7 @@ class Diaspora foreach ($recips as $recip) { logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); + /// @fixme $profile isn't available here self::buildAndTransmit($profile, $recip, "profile", $message, false, "", true); } } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index cadc9a37ea..bf1deba772 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1024,6 +1024,7 @@ class OStatus $orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue; $orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue; + /// @fixme $contact is unavailable here $orig_contact = $contact; $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $orig_contact, false); diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 0fcf6f5743..e0213ca5c4 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -816,6 +816,7 @@ class PortableContact return false; } + /// @fixme $element is unavailable here $server["site_name"] = $xpath->evaluate($element."//head/title/text()")->item(0)->nodeValue; return $server; } diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 8e5383ac0c..42ae1fd997 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -25,6 +25,7 @@ class Directory { $dir .= "/submit"; + /// @fixme $argv is unavailable here $arr = array('url' => $argv[1]); call_hooks('globaldir_update', $arr); From ba7bb04287f94ac1b05feeeed850fe3b6e6cd40b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 15:38:03 -0500 Subject: [PATCH 08/14] Updated composer classmaps --- vendor/composer/autoload_classmap.php | 4 +--- vendor/composer/autoload_static.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 6404d6a9fe..020533182e 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -10,7 +10,6 @@ return array( 'Console_Getopt' => $vendorDir . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php', 'Detection\\MobileDetect' => $vendorDir . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php', 'Friendica\\App' => $baseDir . '/src/App.php', - 'Friendica\\BaseModule' => $baseDir . '/src/BaseModule.php', 'Friendica\\BaseObject' => $baseDir . '/src/BaseObject.php', 'Friendica\\Content\\Feature' => $baseDir . '/src/Content/Feature.php', 'Friendica\\Content\\ForumManager' => $baseDir . '/src/Content/ForumManager.php', @@ -29,7 +28,6 @@ return array( 'Friendica\\Model\\Photo' => $baseDir . '/src/Model/Photo.php', 'Friendica\\Model\\Profile' => $baseDir . '/src/Model/Profile.php', 'Friendica\\Model\\User' => $baseDir . '/src/Model/User.php', - 'Friendica\\Module\\Login' => $baseDir . '/src/Module/Login.php', 'Friendica\\Network\\FKOAuth1' => $baseDir . '/src/Network/FKOAuth1.php', 'Friendica\\Network\\FKOAuthDataStore' => $baseDir . '/src/Network/FKOAuthDataStore.php', 'Friendica\\Network\\HTTPException' => $baseDir . '/src/Network/HTTPException.php', @@ -70,7 +68,7 @@ return array( 'Friendica\\Util\\ExAuth' => $baseDir . '/src/Util/ExAuth.php', 'Friendica\\Util\\Lock' => $baseDir . '/src/Util/Lock.php', 'Friendica\\Util\\Map' => $baseDir . '/src/Util/Map.php', - 'Friendica\\Util\\Pidfile' => $baseDir . '/src/Util/Pidfile.php', + 'Friendica\\Util\\PidFile' => $baseDir . '/src/Util/Pidfile.php', 'Friendica\\Util\\XML' => $baseDir . '/src/Util/XML.php', 'Friendica\\Worker\\CheckVersion' => $baseDir . '/src/Worker/CheckVersion.php', 'Friendica\\Worker\\CreateShadowEntry' => $baseDir . '/src/Worker/CreateShadowEntry.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 5d6fae0838..64eb2948aa 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -63,7 +63,6 @@ class ComposerStaticInitFriendica 'Console_Getopt' => __DIR__ . '/..' . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php', 'Detection\\MobileDetect' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php', 'Friendica\\App' => __DIR__ . '/../..' . '/src/App.php', - 'Friendica\\BaseModule' => __DIR__ . '/../..' . '/src/BaseModule.php', 'Friendica\\BaseObject' => __DIR__ . '/../..' . '/src/BaseObject.php', 'Friendica\\Content\\Feature' => __DIR__ . '/../..' . '/src/Content/Feature.php', 'Friendica\\Content\\ForumManager' => __DIR__ . '/../..' . '/src/Content/ForumManager.php', @@ -82,7 +81,6 @@ class ComposerStaticInitFriendica 'Friendica\\Model\\Photo' => __DIR__ . '/../..' . '/src/Model/Photo.php', 'Friendica\\Model\\Profile' => __DIR__ . '/../..' . '/src/Model/Profile.php', 'Friendica\\Model\\User' => __DIR__ . '/../..' . '/src/Model/User.php', - 'Friendica\\Module\\Login' => __DIR__ . '/../..' . '/src/Module/Login.php', 'Friendica\\Network\\FKOAuth1' => __DIR__ . '/../..' . '/src/Network/FKOAuth1.php', 'Friendica\\Network\\FKOAuthDataStore' => __DIR__ . '/../..' . '/src/Network/FKOAuthDataStore.php', 'Friendica\\Network\\HTTPException' => __DIR__ . '/../..' . '/src/Network/HTTPException.php', @@ -123,7 +121,7 @@ class ComposerStaticInitFriendica 'Friendica\\Util\\ExAuth' => __DIR__ . '/../..' . '/src/Util/ExAuth.php', 'Friendica\\Util\\Lock' => __DIR__ . '/../..' . '/src/Util/Lock.php', 'Friendica\\Util\\Map' => __DIR__ . '/../..' . '/src/Util/Map.php', - 'Friendica\\Util\\Pidfile' => __DIR__ . '/../..' . '/src/Util/Pidfile.php', + 'Friendica\\Util\\PidFile' => __DIR__ . '/../..' . '/src/Util/Pidfile.php', 'Friendica\\Util\\XML' => __DIR__ . '/../..' . '/src/Util/XML.php', 'Friendica\\Worker\\CheckVersion' => __DIR__ . '/../..' . '/src/Worker/CheckVersion.php', 'Friendica\\Worker\\CreateShadowEntry' => __DIR__ . '/../..' . '/src/Worker/CreateShadowEntry.php', From a8b3a2624bb87b8e03e13f29857a51dfefedd399 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:08:22 -0500 Subject: [PATCH 09/14] Fix Protocol\Diaspora missing user variable --- src/Protocol/Diaspora.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 466104c404..5bfebe9f74 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -2316,10 +2316,12 @@ class Diaspora $arr["last-child"] = 1; - $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"]; + $user = dba::select('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]], ['limit' => 1]); + + $arr["allow_cid"] = $user["allow_cid"]; + $arr["allow_gid"] = $user["allow_gid"]; + $arr["deny_cid"] = $user["deny_cid"]; + $arr["deny_gid"] = $user["deny_gid"]; $i = item_store($arr); if ($i) { From e37cf8fea26683ed2223ff2fcc4d7fdccc9f74aa Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:10:44 -0500 Subject: [PATCH 10/14] Fix missing owner in Protocol/Diaspora --- src/Protocol/Diaspora.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 5bfebe9f74..e15c1b7933 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4051,6 +4051,29 @@ class Diaspora return; } + $r = dba::p("SELECT + `contact`.*, + `user`.`prvkey` AS `uprvkey`, + `user`.`timezone`, + `user`.`nickname`, + `user`.`sprvkey`, + `user`.`spubkey`, + `user`.`page-flags`, + `user`.`account-type`, + `user`.`prvnets` + FROM `contact` + INNER JOIN `user` + ON `user`.`uid` = `contact`.`uid` + WHERE `contact`.`uid` = ? + AND `contact`.`self` = 1 + LIMIT 1", + $uid + ); + if (!DBM::is_result($r)) { + return; + } + $owner = $r[0]; + if (!$recips) { $recips = q( "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s' @@ -4069,8 +4092,7 @@ class Diaspora foreach ($recips as $recip) { logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); - /// @fixme $profile isn't available here - self::buildAndTransmit($profile, $recip, "profile", $message, false, "", true); + self::buildAndTransmit($owner, $recip, "profile", $message, false, "", true); } } From df02238659ca702db64b89c5fcf47849f8ae722c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:22:39 -0500 Subject: [PATCH 11/14] Centralize owner data fetch --- src/Model/User.php | 31 +++++++++++++++++++++++++++++++ src/Protocol/Diaspora.php | 22 ++-------------------- src/Worker/Delivery.php | 14 +++----------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index 9762727aca..a43560b019 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -33,6 +33,37 @@ require_once 'include/text.php'; */ class User { + /** + * @brief Get owner data by user id + * + * @param int $uid + * @return boolean|array + */ + public static function getOwnerDataById($uid) { + $r = dba::p("SELECT + `contact`.*, + `user`.`prvkey` AS `uprvkey`, + `user`.`timezone`, + `user`.`nickname`, + `user`.`sprvkey`, + `user`.`spubkey`, + `user`.`page-flags`, + `user`.`account-type`, + `user`.`prvnets` + FROM `contact` + INNER JOIN `user` + ON `user`.`uid` = `contact`.`uid` + WHERE `contact`.`uid` = ? + AND `contact`.`self` = 1 + LIMIT 1", + $uid + ); + if (!DBM::is_result($r)) { + return false; + } + return $r[0]; + } + /** * @brief Returns the default group for a given user and network * diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index e15c1b7933..8828324c54 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4051,28 +4051,10 @@ class Diaspora return; } - $r = dba::p("SELECT - `contact`.*, - `user`.`prvkey` AS `uprvkey`, - `user`.`timezone`, - `user`.`nickname`, - `user`.`sprvkey`, - `user`.`spubkey`, - `user`.`page-flags`, - `user`.`account-type`, - `user`.`prvnets` - FROM `contact` - INNER JOIN `user` - ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`uid` = ? - AND `contact`.`self` = 1 - LIMIT 1", - $uid - ); - if (!DBM::is_result($r)) { + $owner = User::getOwnerDataById($uid); + if (!$owner) { return; } - $owner = $r[0]; if (!$recips) { $recips = q( diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 9ed9a06c17..b3d3ecc140 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -10,6 +10,7 @@ use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Database\DBM; use Friendica\Model\Contact; +use Friendica\Model\User; use Friendica\Protocol\Diaspora; use Friendica\Protocol\DFRN; use Friendica\Protocol\Email; @@ -140,20 +141,11 @@ class Delivery { } } - $r = q("SELECT `contact`.*, `user`.`prvkey` AS `uprvkey`, - `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, - `user`.`page-flags`, `user`.`account-type`, `user`.`prvnets` - FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", - intval($uid) - ); - - if (!DBM::is_result($r)) { + $owner = User::getOwnerDataById($uid); + if (!$owner) { return; } - $owner = $r[0]; - $walltowall = (($top_level && ($owner['id'] != $items[0]['contact-id'])) ? true : false); $public_message = true; From b8e41906a4c0ba8d82d5cce6ae59bc5515462e80 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:22:58 -0500 Subject: [PATCH 12/14] Remove unused variable in Protocol\PortableContact --- src/Protocol/PortableContact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index e0213ca5c4..ccae5520b3 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -817,7 +817,7 @@ class PortableContact } /// @fixme $element is unavailable here - $server["site_name"] = $xpath->evaluate($element."//head/title/text()")->item(0)->nodeValue; + $server["site_name"] = $xpath->evaluate("//head/title/text()")->item(0)->nodeValue; return $server; } From 872190dcb066914833608bd7e5858f570c4bc613 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:25:32 -0500 Subject: [PATCH 13/14] Fix missing variable in Worker\Directory - Remove fixed comment in PortableContact --- src/Protocol/PortableContact.php | 1 - src/Worker/Directory.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index ccae5520b3..04b16a72db 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -816,7 +816,6 @@ class PortableContact return false; } - /// @fixme $element is unavailable here $server["site_name"] = $xpath->evaluate("//head/title/text()")->item(0)->nodeValue; return $server; } diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 42ae1fd997..8dafbfaaa5 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -25,8 +25,7 @@ class Directory { $dir .= "/submit"; - /// @fixme $argv is unavailable here - $arr = array('url' => $argv[1]); + $arr = array('url' => $url); call_hooks('globaldir_update', $arr); From 98daf58cda9b9bd459fc3b21db673dbe5f81bc74 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 16:32:35 -0500 Subject: [PATCH 14/14] Fix undefined variable in Protocol\OStatus --- src/Protocol/OStatus.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index bf1deba772..757c525f96 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1024,9 +1024,7 @@ class OStatus $orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue; $orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue; - /// @fixme $contact is unavailable here - $orig_contact = $contact; - $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $orig_contact, false); + $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $dummy, false); $item["author-name"] = $orig_author["author-name"]; $item["author-link"] = $orig_author["author-link"];