From 308d64069f8903a113985d7d71d027b127a3b0ce Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 31 Oct 2023 12:32:47 +0100 Subject: [PATCH] fix(Step): Use largest possible 32-bit int value for transition The value used before (largest possible MySQL BIGINT value) was too big for PHP int. Since we still support 32-bit platforms on Nextcloud, let's stick to the largest possible 32-bit PHP integer value. Besides, setting the value as default for `Step::version` doesn't work as `QBMapper->insert()` doesn't recognize the `version` field as changed in that case. So let's default to `0` again and set it using `Step->setVersion()` later. Signed-off-by: Jonas --- lib/Db/Step.php | 6 +++--- lib/Service/DocumentService.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Db/Step.php b/lib/Db/Step.php index 9558178c033..52377fcd144 100644 --- a/lib/Db/Step.php +++ b/lib/Db/Step.php @@ -41,13 +41,13 @@ class Step extends Entity implements JsonSerializable { /* * Transition: We now use the auto-incrementing id as the version. * To ensure that new steps always have a larger version than those that - * used the version field, use the largest possible value for BIGINT. + * used the version field, use the largest possible 32-bit integer value. */ - public const VERSION_STORED_IN_ID = 18446744073709551615; + public const VERSION_STORED_IN_ID = 2147483647; public $id = null; protected string $data = ''; - protected int $version = self::VERSION_STORED_IN_ID; + protected int $version = 0; protected int $sessionId = 0; protected int $documentId = 0; diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index 7cf14929f48..2998112e86c 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -263,6 +263,7 @@ private function insertSteps(Document $document, Session $session, array $steps) $step->setData($stepsJson); $step->setSessionId($session->getId()); $step->setDocumentId($document->getId()); + $step->setVersion(Step::VERSION_STORED_IN_ID); $step = $this->stepMapper->insert($step); $newVersion = $step->getId(); $this->logger->debug("Adding steps to " . $document->getId() . ": bumping version from $stepsVersion to $newVersion");