From fc1c014da0f44a8f443959aaa8b74cfa6f7e4fea Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Thu, 18 May 2023 07:52:28 +0200 Subject: [PATCH 1/2] Upgrade feed-io to v5.1.3 Signed-off-by: Benjamin Brahmer --- CHANGELOG.md | 1 + composer.json | 4 +- composer.lock | 168 ++++++++++++++-------------- lib/Fetcher/Client/FeedIoClient.php | 8 +- lib/Fetcher/FeedFetcher.php | 2 +- 5 files changed, 92 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed7d4cccea..a3029c6f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 ## [23.x.x] ### Changed - Drop support for PHP 7.4 new min. version is php 8.0 +- Upgrade feed-io to v5.1.3 ### Fixed ## [22.x.x] diff --git a/composer.json b/composer.json index 42055a5153..0e91f52871 100644 --- a/composer.json +++ b/composer.json @@ -40,11 +40,11 @@ "source": "https://github.com/nextcloud/news/" }, "require": { - "php": "^7.4 || ~8.0", + "php": "~8.0", "ezyang/htmlpurifier": "^4.16.0", "pear/net_url2": "^2.2.2", "riimu/kit-pathjoin": "^1.2.0", - "debril/feed-io": "^v4.9.12", + "debril/feed-io": "^v5.3.1", "arthurhoaro/favicon": "^1.3.3", "fivefilters/readability.php": "^3.1", "ext-json": "*", diff --git a/composer.lock b/composer.lock index 10ce758a9d..edb56487dd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "66340fbabc652170d2c025618a6eb32f", + "content-hash": "d1b3dae961ec41e0e94f78ec46b631a6", "packages": [ { "name": "arthurhoaro/favicon", @@ -66,16 +66,16 @@ }, { "name": "debril/feed-io", - "version": "v4.9.15", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/alexdebril/feed-io.git", - "reference": "1c45bd07837123ec6eacf8cdd612cbb0dc27229c" + "reference": "b1237713ae174fc4dd57aff1e472303a1162ccfc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alexdebril/feed-io/zipball/1c45bd07837123ec6eacf8cdd612cbb0dc27229c", - "reference": "1c45bd07837123ec6eacf8cdd612cbb0dc27229c", + "url": "https://api.github.com/repos/alexdebril/feed-io/zipball/b1237713ae174fc4dd57aff1e472303a1162ccfc", + "reference": "b1237713ae174fc4dd57aff1e472303a1162ccfc", "shasum": "" }, "require": { @@ -83,13 +83,13 @@ "ext-json": "*", "ext-libxml": "*", "guzzlehttp/guzzle": "~6.2|~7.0", - "php": ">=7.1", - "psr/log": "~1.0", - "symfony/console": "~3.4|~4.0|~5.0|~6.0" + "php": ">=8.0", + "psr/log": "~1.0|~2.0|~3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.4", - "monolog/monolog": "1.*", + "friendsofphp/php-cs-fixer": "^3.5", + "monolog/monolog": "1.*|2.*", + "phpstan/phpstan": "^0.12.81", "phpunit/phpunit": "~9.3.0" }, "suggest": { @@ -127,9 +127,9 @@ ], "support": { "issues": "https://github.com/alexdebril/feed-io/issues", - "source": "https://github.com/alexdebril/feed-io/tree/v4.9.15" + "source": "https://github.com/alexdebril/feed-io/tree/v5.3.1" }, - "time": "2022-10-26T20:16:20+00:00" + "time": "2022-10-26T20:20:14+00:00" }, { "name": "ezyang/htmlpurifier", @@ -429,16 +429,16 @@ }, { "name": "masterminds/html5", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/Masterminds/html5-php.git", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3" + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f47dcf3c70c584de14f21143c55d9939631bc6cf", + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf", "shasum": "" }, "require": { @@ -490,9 +490,9 @@ ], "support": { "issues": "https://github.com/Masterminds/html5-php/issues", - "source": "https://github.com/Masterminds/html5-php/tree/2.8.0" + "source": "https://github.com/Masterminds/html5-php/tree/2.8.1" }, - "time": "2023-04-26T07:27:39+00:00" + "time": "2023-05-10T11:58:31+00:00" }, { "name": "pear/net_url2", @@ -925,30 +925,29 @@ }, { "name": "doctrine/event-manager", - "version": "1.2.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", "shasum": "" }, "require": { - "doctrine/deprecations": "^0.5.3 || ^1", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "conflict": { "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "~1.4.10 || ^1.8.8", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.24" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.28" }, "type": "library", "autoload": { @@ -997,7 +996,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.2.0" + "source": "https://github.com/doctrine/event-manager/tree/2.0.0" }, "funding": [ { @@ -1013,34 +1012,34 @@ "type": "tidelift" } ], - "time": "2022-10-12T20:51:15+00:00" + "time": "2022-10-12T20:59:15+00:00" }, { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -1067,7 +1066,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -1083,7 +1082,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "myclabs/deep-copy", @@ -1357,16 +1356,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.26", + "version": "1.10.27", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "5d660cbb7e1b89253a47147ae44044f49832351f" + "reference": "a9f44dcea06f59d1363b100bb29f297b311fa640" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5d660cbb7e1b89253a47147ae44044f49832351f", - "reference": "5d660cbb7e1b89253a47147ae44044f49832351f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a9f44dcea06f59d1363b100bb29f297b311fa640", + "reference": "a9f44dcea06f59d1363b100bb29f297b311fa640", "shasum": "" }, "require": { @@ -1415,25 +1414,25 @@ "type": "tidelift" } ], - "time": "2023-07-19T12:44:37+00:00" + "time": "2023-08-05T09:57:55+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "a22b36b955a2e9a3d39fe533b6c1bb5359f9c319" + "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/a22b36b955a2e9a3d39fe533b6c1bb5359f9c319", - "reference": "a22b36b955a2e9a3d39fe533b6c1bb5359f9c319", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", + "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10.3" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", @@ -1461,22 +1460,22 @@ "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", "support": { "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.3" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.4" }, - "time": "2023-03-17T07:50:08+00:00" + "time": "2023-08-05T09:02:04+00:00" }, { "name": "phpstan/phpstan-doctrine", - "version": "1.3.40", + "version": "1.3.41", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-doctrine.git", - "reference": "f741919a720af6f84249abc62befeb15eee7bc88" + "reference": "69aaa52dd8b7c8f0c806f81cea2afe5f87ca838b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/f741919a720af6f84249abc62befeb15eee7bc88", - "reference": "f741919a720af6f84249abc62befeb15eee7bc88", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/69aaa52dd8b7c8f0c806f81cea2afe5f87ca838b", + "reference": "69aaa52dd8b7c8f0c806f81cea2afe5f87ca838b", "shasum": "" }, "require": { @@ -1504,8 +1503,8 @@ "nesbot/carbon": "^2.49", "nikic/php-parser": "^4.13.2", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.3.13", + "phpstan/phpstan-strict-rules": "^1.5.1", "phpunit/phpunit": "^9.5.10", "ramsey/uuid-doctrine": "^1.5.0", "symfony/cache": "^4.4.35" @@ -1531,9 +1530,9 @@ "description": "Doctrine extensions for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-doctrine/issues", - "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.3.40" + "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.3.41" }, - "time": "2023-05-11T11:26:04+00:00" + "time": "2023-08-08T07:47:54+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -1638,16 +1637,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.26", + "version": "9.2.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1" + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", - "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", "shasum": "" }, "require": { @@ -1703,7 +1702,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" }, "funding": [ { @@ -1711,7 +1711,7 @@ "type": "github" } ], - "time": "2023-03-06T12:58:08+00:00" + "time": "2023-07-26T13:44:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2059,20 +2059,20 @@ }, { "name": "psr/cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { @@ -2092,7 +2092,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for caching libraries", @@ -2102,9 +2102,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2016-08-06T20:24:11+00:00" + "time": "2021-02-03T23:26:27+00:00" }, { "name": "sebastian/cli-parser", @@ -2612,16 +2612,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -2664,7 +2664,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -2672,7 +2672,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -3184,7 +3184,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.4 || ~8.0", + "php": "~8.0", "ext-json": "*", "ext-simplexml": "*", "ext-libxml": "*", diff --git a/lib/Fetcher/Client/FeedIoClient.php b/lib/Fetcher/Client/FeedIoClient.php index ac1f62a1f6..fe57c5889d 100644 --- a/lib/Fetcher/Client/FeedIoClient.php +++ b/lib/Fetcher/Client/FeedIoClient.php @@ -38,14 +38,14 @@ public function __construct(\GuzzleHttp\ClientInterface $guzzleClient) } /** - * @param string $url - * @param DateTime $modifiedSince + * @param string $url + * @param DateTime|null $modifiedSince * * @return ResponseInterface * @throws ServerErrorException|GuzzleException * @throws NotFoundException */ - public function getResponse(string $url, DateTime $modifiedSince) : ResponseInterface + public function getResponse(string $url, ?DateTime $modifiedSince = null) : ResponseInterface { $modifiedSince->setTimezone(new \DateTimeZone('GMT')); try { @@ -65,7 +65,7 @@ public function getResponse(string $url, DateTime $modifiedSince) : ResponseInte case 404: throw new NotFoundException($e->getMessage()); default: - throw new ServerErrorException($e->getMessage()); + throw new ServerErrorException($e->getResponse()); } } } diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php index 60d7988894..9fdee1d976 100755 --- a/lib/Fetcher/FeedFetcher.php +++ b/lib/Fetcher/FeedFetcher.php @@ -127,7 +127,7 @@ public function fetch( $lastModified = null; } $url = $url2->getNormalizedURL(); - $this->reader->resetFilters(); + $resource = $this->reader->read($url, null, $lastModified); $location = $resource->getUrl(); From 312834529e8d5c451dac3cd32db12fe2fcad78c8 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Thu, 18 May 2023 08:25:43 +0200 Subject: [PATCH 2/2] add Test for old items Signed-off-by: Benjamin Brahmer --- tests/test_helper/php-feed-generator | 2 +- tests/updater/update.bats | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/test_helper/php-feed-generator b/tests/test_helper/php-feed-generator index 7cc1604810..50b6010a2e 160000 --- a/tests/test_helper/php-feed-generator +++ b/tests/test_helper/php-feed-generator @@ -1 +1 @@ -Subproject commit 7cc16048103bf31e9a4b54293e8bbc6049a874c1 +Subproject commit 50b6010a2e93b58bbc04468af7a9242fee7a4440 diff --git a/tests/updater/update.bats b/tests/updater/update.bats index ba978dbb01..e55661bc10 100644 --- a/tests/updater/update.bats +++ b/tests/updater/update.bats @@ -85,6 +85,33 @@ teardown() { assert_output --partial "${ID_LIST1[*]}" } +@test "[$TESTSUITE] Test feed with 'outdated' items https://github.com/nextcloud/news/issues/2236 " { + # Create Feed, for the first fetch a timestamp today -1 year is used. + FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)') + + sleep 2 + + # Get Items + ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + + # Generate Feed with older items (-o yes) + php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 15 -s 9 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml -o yes + + # Trigger Update + http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID + + sleep 2 + + # Get Items again + ID_LIST2=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + + output="${ID_LIST2[*]}" + + # Check that they are not equal but that they match partially. + assert_not_equal "${ID_LIST1[*]}" "${ID_LIST2[*]}" + assert_output --partial "${ID_LIST1[*]}" +} + @test "[$TESTSUITE] Test purge with small feed" { # Generate Feed with 210 items. php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 50 -s 0 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml