diff options
author | Joas Schilling <coding@schilljs.com> | 2025-05-17 22:08:16 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-05-17 22:08:16 +0200 |
commit | 112fa8d3ead957e802edc6446a3ed550c9860630 (patch) | |
tree | fa7fe76d4008f3c57b6fe67f0bfaf5c4f4aef879 | |
parent | 2795efc2ace822075810a523eb6e34dbf94e1bb9 (diff) | |
download | nextcloud-server-tests/noid/debug-systemkeeper.tar.gz nextcloud-server-tests/noid/debug-systemkeeper.zip |
fix(database): Only return the previously stored lastInsertId when we didn't get onetests/noid/debug-systemkeeper
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/DB/Connection.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 93d493507af..dd55e40fab8 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -529,12 +529,13 @@ class Connection extends PrimaryReadReplicaConnection { * @throws Exception */ public function realLastInsertId($seqName = null): int { - if ($this->lastInsertId !== 0) { - $lastInsertId = $this->lastInsertId; - $this->lastInsertId = 0; - return $lastInsertId; + $previousLastInsertId = $this->lastInsertId; + $lastInsertId = (int)parent::lastInsertId($seqName); + if ($lastInsertId === 0 && $previousLastInsertId !== 0) { + $lastInsertId = $previousLastInsertId; } - return (int)parent::lastInsertId($seqName); + $this->lastInsertId = 0; + return $lastInsertId; } /** |