From 60e477423f8de379a8ddbf7bd9d72aecb6fc5a70 Mon Sep 17 00:00:00 2001 From: Raed <91275175+Raed2180416@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:22:00 +0530 Subject: [PATCH] Fix TypeError from entry IDs on 32-bit platforms (#9578) An integer literal above PHP_INT_MAX is a float on x86, and _id() only accepted int|string, so the export test failed there with "must be of type string|int, float given". * Build entry IDs as strings in the tests 1700000000000000 + $i is a float on 32-bit platforms, where it exceeds PHP_INT_MAX, and FreshRSS_Entry::_id() rejects it. Entry IDs are strings everywhere else, since uTimeString() and the DAO layer both produce numeric strings, so keep the ID a string in the test instead of accepting a float. A test now pins that contract. Refs #9569 --------- Co-authored-by: Raed --- tests/app/Models/EntryTest.php | 8 ++++++++ tests/app/Views/exportArticlesTest.php | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/app/Models/EntryTest.php b/tests/app/Models/EntryTest.php index 75af92e69..b3f7b5588 100644 --- a/tests/app/Models/EntryTest.php +++ b/tests/app/Models/EntryTest.php @@ -109,4 +109,12 @@ final class EntryTest extends \PHPUnit\Framework\TestCase { self::assertSame('A & B', $item['title']); self::assertSame('B & C', $item['author']); } + + /** Above PHP_INT_MAX, an integer literal is a float on 32-bit platforms, so an entry ID is only ever a string */ + public function test_idRejectsAFloat(): void { + $entry = new FreshRSS_Entry(1, 'guid-1', 'Title', '', '', 'https://example.net/1', 1700000000); + $this->expectException(\TypeError::class); + // @phpstan-ignore argument.type + $entry->_id(1700000000000001.0); + } } diff --git a/tests/app/Views/exportArticlesTest.php b/tests/app/Views/exportArticlesTest.php index 6ba90fe6d..913f0c0ef 100644 --- a/tests/app/Views/exportArticlesTest.php +++ b/tests/app/Views/exportArticlesTest.php @@ -28,7 +28,8 @@ final class exportArticlesTest extends \PHPUnit\Framework\TestCase { for ($i = 1; $i <= $count; $i++) { $entry = new FreshRSS_Entry(1, 'guid-' . $i, 'Title ' . $i, '', str_repeat('

Contenu exporté ' . $i . '

', 200), 'https://example.net/' . $i, 1700000000 + $i); - $entry->_id(1700000000000000 + $i); + // A string, because this value exceeds PHP_INT_MAX on 32-bit platforms and would be a float there + $entry->_id('17000000000000' . sprintf('%02d', $i)); // @phpstan-ignore argument.type (numeric-string) $entries[] = $entry; } return $entries;