diff --git a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php index 31ed4d15bd..b92fa7ea03 100644 --- a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php +++ b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php @@ -18,6 +18,8 @@ final class SqliteGateway implements Gateway */ private const FATAL_ERROR_CODE = 7; + private const DB_INT_MAX = 2147483647; + /** @var array */ private $lastInsertedIds = []; @@ -27,7 +29,7 @@ public function getColumnNextIntegerValue( string $sequenceName ): ?int { $lastId = $this->lastInsertedIds[$sequenceName] ?? 0; - $nextId = (int)hrtime(true); + $nextId = (int)hrtime(true) % self::DB_INT_MAX; // $lastId === $nextId shouldn't happen using high-resolution time, but better safe than sorry return $this->lastInsertedIds[$sequenceName] = $lastId === $nextId ? $nextId + 1 : $nextId;