From 8d58cbe77f352644ee92708d2c4c8180854a6f8a Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 15 Jan 2026 07:19:52 +0000 Subject: [PATCH 1/3] Exclude some more unwanted files from the package These files aren't needed in the Composer package. --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index efc16726d..a9f0731e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,9 +4,12 @@ /compatibility_test export-ignore /demo export-ignore /tests export-ignore +/utils/PHPStan export-ignore .gitattributes export-ignore .editorconfig export-ignore .gitignore export-ignore ROADMAP.md export-ignore phpunit.xml.dist export-ignore .php-cs-fixer.dist.php export-ignore +db.sql export-ignore +phpstan.dist.neon export-ignore From ae7dec6138d9b13e5898ccfe97da07b8baaa1212 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 15 Jan 2026 08:04:47 +0100 Subject: [PATCH 2/3] File: Drop curl 7.10.5 conditional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP 7.2 requires at least libcurl 7.10.5 so the check is always true on all supported PHP versions: https://github.com/php/php-src/blob/php-7.2.0/ext/curl/config.m4#L34 PHP 7.3 bumps the minimum to 7.15.5 but, even when we drop support for PHP < 7.4, that won’t help us with cleanups: https://github.com/php/php-src/blob/php-7.3.0/ext/curl/config.m4#L32 PHP 8.0 further bumps this to 7.29.0, which would allow us to remove the remaining conditionals, but we still support 7.2.0 for now and will support 7.4.0 for a while. https://github.com/php/php-src/blob/php-8.0.0/ext/curl/config.m4#L7 --- src/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/File.php b/src/File.php index 7dc2e120a..e0ce712be 100644 --- a/src/File.php +++ b/src/File.php @@ -123,7 +123,7 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5, } if (version_compare(\SimplePie\Misc::get_curl_version(), '7.21.6', '>=')) { curl_setopt($fp, CURLOPT_ACCEPT_ENCODING, ''); - } elseif (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) { + } else { curl_setopt($fp, CURLOPT_ENCODING, ''); } curl_setopt($fp, CURLOPT_URL, $url); From 63bd4b7f3f081232e428de9fe6f8b0982e77bf52 Mon Sep 17 00:00:00 2001 From: Alayn Gortazar Date: Fri, 16 Jan 2026 09:18:26 +0100 Subject: [PATCH 3/3] fix: Return null instead of error or today date for invalid date formats Fixes date parsing behavior when encountering invalid or localized date formats. Before (on PHP 7.4): - Invalid dates could throw errors/warnings due to `strict_types` Before (on PHP 8.*): - Invalid dates returned current date when not properly parsed (`date` uses current time when passed null) After: - Invalid dates gracefully return null - Consistent behavior for different PHP versions Changes: - Improved error handling in date parsing - Added test coverage for RFC 2822 formatted dates - Added test for custom format parameter --- src/Item.php | 2 +- tests/Unit/ItemTest.php | 49 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/Item.php b/src/Item.php index c2f7460c6..0a7cf151d 100644 --- a/src/Item.php +++ b/src/Item.php @@ -672,7 +672,7 @@ public function get_date(string $date_format = 'j F Y, g:i a') return $this->data['date']['parsed']; default: - return date($date_format, $this->data['date']['parsed']); + return $this->data['date']['parsed'] !== null ? date($date_format, $this->data['date']['parsed']) : null; } } diff --git a/tests/Unit/ItemTest.php b/tests/Unit/ItemTest.php index 589c65698..a0fa8b5de 100644 --- a/tests/Unit/ItemTest.php +++ b/tests/Unit/ItemTest.php @@ -663,7 +663,7 @@ public function test_get_content(string $data, string $expected): void } /** - * @return array + * @return array */ public static function getDateDataProvider(): array { @@ -1318,13 +1318,56 @@ public static function getDateDataProvider(): array , 1168531200, ], + 'Test RFC 2822 formatted date' => [ +<< + + + Thu, 11 Jan 2007 16:00:00 +0000 + + + +XML + , + 1168531200 + ], + 'Test date is properly formatted' => [ +<< + + + Thu, 11 Jan 2007 16:00:00 +0000 + + + +XML + , + '2007-01-11', + 'Y-m-d' + ], + 'Invalid format: localized RFC 2822 formatted date' => [ +<< + + + Ost, 11 Urt 2007 16:00:00 +0000 + + + +XML + , + null, + 'Y-m-d' + ], ]; } /** + * @param int|string|null $expected + * * @dataProvider getDateDataProvider */ - public function test_get_date(string $data, ?int $expected): void + public function test_get_date(string $data, $expected, string $format = 'U'): void { $feed = new SimplePie(); $feed->set_raw_data($data); @@ -1334,7 +1377,7 @@ public function test_get_date(string $data, ?int $expected): void $item = $feed->get_item(0); self::assertInstanceOf(Item::class, $item); - self::assertSame($expected, $item->get_date('U')); + self::assertSame($expected, $item->get_date($format)); } /**