From 882deab455fb7b6ca020391a33bff24e088c62bf Mon Sep 17 00:00:00 2001 From: Artur Weigandt Date: Sat, 14 Sep 2024 23:11:10 +0200 Subject: Allow SimplePie updates with composer (#4374) * rename lib/SimplePie to lib/CustomSimplePie * add test for autoloading SimplePie with PSR-0 * install SimplePie 1.6.0 * Add SimplePie CHANGELOG.md, ignore irrelevant files * remove unmodified custom classes * rename all customized SimplePie classes * Add autoloading for SimplePie PSR-0 and CustomSimplePie classes * let CustomSimplePie extends SimplePie, remove unchanged code * let CustomSimplePieMisc extends SimplePie\Misc, remove unchanged code * Add tests for autoloading * let CustomSimplePieContentTypeSniffer extends Sniffer, remove unchanged code * remove unchanged CustomSimplePieEnclosure class The fixed typos are commited to SimplePie See https://github.com/simplepie/simplepie/pull/722/commits/133eac158cddaf5d2ddf9d9e5f42d92f944f885d * let CustomSimplePieFile extends SimplePie\File, remove unchanged code * let CustomSimplePieParser extends SimplePie\Parser, remove unchanged code * let CustomSimplePieSanitize extends SimplePie\Sanitize, remove unchanged code * let CustomSimplePieHttpParser extends SimplePie\HTTP\Parser, remove unchanged code * Remove CustomSimplePie * Switch SimplePie repo to https://github.com/FreshRSS/simplepie.git * move to latest branch, update all SimplePie source files * Use namespaced SimplePie classes, remove SimplePie library folder * Update to latest SimplePie version with FreshRSS modifications * Bump SimplePie Tests expected to fail due to missing a backport of functionalities * Add fork-specific readme * Re-implement initial syslog SimplePie GET https://github.com/FreshRSS/FreshRSS/pull/815 Lacks https://github.com/FreshRSS/FreshRSS/pull/6061 * Closer backport of syslog SimplePie GET https://github.com/FreshRSS/FreshRSS/pull/6061 But the requests logs will be in the wrong order in case of redirections * Fixes * lib update * SimplePie include a few more files * Try with cache-hash branch * Point to newer commit * Point to newer commit * Finalise logs * Finalise * Bump SimplePie commit * Bump SimplePie commit * Readme SimplePie fork * Bump SimplePie commit * Better logging * Bump SimplePie commit * Reworked approach to work with SimplePie cache Simpler FreshRSS patches * Bump SimplePie commit https://github.com/FreshRSS/simplepie/pull/22 * Simplepie846 https://github.com/FreshRSS/simplepie/pull/23 And additional fixes * Remove log * Cherry pick relevant unmerged SimplePie PRs --------- Co-authored-by: Alexandre Alapetite --- app/Controllers/feedController.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 app/Controllers/feedController.php (limited to 'app/Controllers/feedController.php') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php old mode 100644 new mode 100755 index 3f4ed3149..9c4860521 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -385,7 +385,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { * list of feeds for which a cache refresh is needed * @throws FreshRSS_BadUrl_Exception */ - public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url = null, ?int $maxFeeds = null, ?SimplePie $simplePiePush = null): array { + public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url = null, ?int $maxFeeds = null, + ?\SimplePie\SimplePie $simplePiePush = null): array { if (function_exists('set_time_limit')) { @set_time_limit(300); } @@ -443,6 +444,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { } $url = $feed->url(); //For detection of HTTP 301 + $oldSimplePieHash = $feed->attributeString('SimplePieHash'); $pubSubHubbubEnabled = $pubsubhubbubEnabledGeneral && $feed->pubSubHubbubEnabled(); if ($simplePiePush === null && $feed_id === null && $pubSubHubbubEnabled && ($feed->lastUpdate() > $pshbMinAge)) { @@ -619,7 +621,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { if ($pubSubHubbubEnabled && $simplePiePush === null) { //We use push, but have discovered an article by pull! $text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' . - SimplePie_Misc::url_remove_credentials($url) . + \SimplePie\Misc::url_remove_credentials($url) . ' GUID ' . $entry->guid(); Minz_Log::warning($text, PSHB_LOG); Minz_Log::warning($text); @@ -657,6 +659,9 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { } $feedProperties = []; + if ($oldSimplePieHash !== $feed->attributeString('SimplePieHash')) { + $feedProperties['attributes'] = $feed->attributes(); + } if ($pubsubhubbubEnabledGeneral && $feed->hubUrl() !== '' && $feed->selfUrl() !== '') { //selfUrl has priority for WebSub if ($feed->selfUrl() !== $url) { // https://github.com/pubsubhubbub/PubSubHubbub/wiki/Moving-Feeds-or-changing-Hubs @@ -672,8 +677,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { } } } elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently - Minz_Log::notice('Feed ' . SimplePie_Misc::url_remove_credentials($url) . - ' moved permanently to ' . SimplePie_Misc::url_remove_credentials($feed->url(false))); + Minz_Log::notice('Feed ' . \SimplePie\Misc::url_remove_credentials($url) . + ' moved permanently to ' . \SimplePie\Misc::url_remove_credentials($feed->url(false))); $feedProperties['url'] = $feed->url(); } @@ -798,7 +803,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { * list of feeds for which a cache refresh is needed * @throws FreshRSS_BadUrl_Exception */ - public static function actualizeFeedsAndCommit(?int $feed_id = null, ?string $feed_url = null, ?int $maxFeeds = null, ?SimplePie $simplePiePush = null): array { + public static function actualizeFeedsAndCommit(?int $feed_id = null, ?string $feed_url = null, ?int $maxFeeds = null, + ?SimplePie\SimplePie $simplePiePush = null): array { $entryDAO = FreshRSS_Factory::createEntryDao(); [$nbUpdatedFeeds, $feed, $nbNewArticles, $feedsCacheToRefresh] = FreshRSS_feed_Controller::actualizeFeeds($feed_id, $feed_url, $maxFeeds, $simplePiePush); if ($nbNewArticles > 0) { -- cgit v1.2.3