From c8fa6ef3dce8af8a032ae901c0885daf5570472c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Sep 2020 16:33:29 -0400 Subject: [PATCH 1/3] Remove validity check on profile key parameter --- src/classes/Pollers/Profile.php | 3 --- src/classes/Utils/Scrape.php | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/classes/Pollers/Profile.php b/src/classes/Pollers/Profile.php index 9b12aef..42b0020 100644 --- a/src/classes/Pollers/Profile.php +++ b/src/classes/Pollers/Profile.php @@ -333,9 +333,6 @@ class Profile private static function validateParams(array $params): int { $errors = 0; - if (empty($params['key'])) { - $errors++; - } if (empty($params['dfrn-request'])) { $errors++; } diff --git a/src/classes/Utils/Scrape.php b/src/classes/Utils/Scrape.php index 758147c..2189b58 100644 --- a/src/classes/Utils/Scrape.php +++ b/src/classes/Utils/Scrape.php @@ -129,7 +129,7 @@ class Scrape $nodes_left = max(intval($max_nodes), $minNodes); $items = $dom->getElementsByTagName('*'); - $targets = array('fn', 'pdesc', 'photo', 'key', 'locality', 'region', 'postal-code', 'country-name'); + $targets = array('fn', 'pdesc', 'photo', 'locality', 'region', 'postal-code', 'country-name'); $targets_left = count($targets); foreach ($items as $item) { if (self::attributeContains($item->getAttribute('class'), 'vcard')) { @@ -147,10 +147,6 @@ class Scrape $params['photo'] = $vcard_element->getAttribute('src'); $targets_left = self::popScrapeTarget($targets, 'photo'); } - if (self::attributeContains($vcard_element->getAttribute('class'), 'key')) { - $params['key'] = $vcard_element->textContent; - $targets_left = self::popScrapeTarget($targets, 'key'); - } if (self::attributeContains($vcard_element->getAttribute('class'), 'locality')) { $params['locality'] = $vcard_element->textContent; $targets_left = self::popScrapeTarget($targets, 'locality'); -- 2.45.3 From c21642d7058a2c73926cbb47e90e36101450adea Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Sep 2020 16:33:55 -0400 Subject: [PATCH 2/3] Improve logging for invalid parameters during profile polling --- src/classes/Pollers/Profile.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/classes/Pollers/Profile.php b/src/classes/Pollers/Profile.php index 42b0020..ca43237 100644 --- a/src/classes/Pollers/Profile.php +++ b/src/classes/Pollers/Profile.php @@ -9,6 +9,10 @@ use Friendica\Directory\Utils\Network; */ class Profile { + const PROFILE_MISSING_REQUEST = 1; + const PROFILE_MISSING_CONFIRM = 2; + const PROFILE_MISSING_NOTIFY = 4; + const PROFILE_MISSING_POLL = 8; /** * @var \Atlas\Pdo\Connection @@ -171,8 +175,21 @@ class Profile } // This is most likely a problem with the site configuration. Ignore. - if (self::validateParams($params)) { + if ($error = self::validateParams($params)) { $this->logger->warning('Poll aborted, parameters invalid.', ['params' => $params]); + if ($error & Profile::PROFILE_MISSING_REQUEST) { + $this->logger->notice('dfrn-request parameter is empty.'); + } + if ($error & Profile::PROFILE_MISSING_CONFIRM) { + $this->logger->notice('dfrn-confirm parameter is empty.'); + } + if ($error & Profile::PROFILE_MISSING_NOTIFY) { + $this->logger->notice('dfrn-notify parameter is empty.'); + } + if ($error & Profile::PROFILE_MISSING_POLL) { + $this->logger->notice('dfrn-poll parameter is empty.'); + } + return false; } @@ -330,20 +347,24 @@ class Profile return true; } + /** + * @param array $params + * @return int + */ private static function validateParams(array $params): int { $errors = 0; if (empty($params['dfrn-request'])) { - $errors++; + $errors &= self::PROFILE_MISSING_REQUEST; } if (empty($params['dfrn-confirm'])) { - $errors++; + $errors &= self::PROFILE_MISSING_CONFIRM; } if (empty($params['dfrn-notify'])) { - $errors++; + $errors &= self::PROFILE_MISSING_NOTIFY; } if (empty($params['dfrn-poll'])) { - $errors++; + $errors &= self::PROFILE_MISSING_POLL; } return $errors; -- 2.45.3 From ca0bb09f81321688a0d0039da12d84386009b164 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Sep 2020 17:06:40 -0400 Subject: [PATCH 3/3] [Database v0006] Drop unused server.path field - Fix "Field 'path' doesn't have a default value" errors --- src/sql/migrations/down/0005.sql | 3 +++ src/sql/migrations/up/0006.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 src/sql/migrations/down/0005.sql create mode 100644 src/sql/migrations/up/0006.sql diff --git a/src/sql/migrations/down/0005.sql b/src/sql/migrations/down/0005.sql new file mode 100644 index 0000000..777a78f --- /dev/null +++ b/src/sql/migrations/down/0005.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE `server` ADD `path` varchar(190) NOT NULL DEFAULT '' AFTER `base_url`; +COMMIT; diff --git a/src/sql/migrations/up/0006.sql b/src/sql/migrations/up/0006.sql new file mode 100644 index 0000000..3b4478b --- /dev/null +++ b/src/sql/migrations/up/0006.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE `server` DROP COLUMN `path`; +COMMIT; -- 2.45.3