mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-12-04 00:04:52 -05:00
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 <Raed2180416@users.noreply.github.com>
This commit is contained in:
1 parent
735c3690b1
commit
60e477423f
2 files changed
+10
-1
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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('<p>Contenu exporté ' . $i . '</p>', 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;
|
||||
|
||||
Reference in new issue
Block a user