Skip to content
This repository was archived by the owner on Aug 14, 2026. It is now read-only.

Commit be71ed9

Browse files
committed
fix: improve file sorting in EntryRepository by using usort for numeric IDs
1 parent 9b1916c commit be71ed9

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/Config.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
final class Config
3030
{
3131
/** @var string */
32-
private string $version = '0.2.1';
32+
private string $version = '0.2.2';
3333

3434
/** @var self */
3535
private static self $instance;

‎src/Storage/EntryRepository.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ public function findNewerThan(string $sessionId, int $afterId): array
120120
return [];
121121
}
122122

123-
sort($files, SORT_STRING);
123+
usort($files, static function (string $a, string $b): int {
124+
$aId = (int) basename($a, '.json');
125+
$bId = (int) basename($b, '.json');
126+
127+
return $aId <=> $bId;
128+
});
124129

125130
/** @var list<array{id: int, session_id: string, request_id: string, data: string, meta: string, timestamp: float, created_at: string}> $results */
126131
$results = [];

0 commit comments

Comments
 (0)