From b5186b01f1bc65ac8c4228e9e86cea2064883808 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Sat, 12 Jun 2021 23:51:53 +0200 Subject: =?UTF-8?q?=F0=9F=9A=91=20Item:=20set=20id=20to=20null=20in=20clon?= =?UTF-8?q?e=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done to set the id to null BEFORE resetting the updated fields. The purpose of this is to avoid explicitly adding a NULL id into the DB, which provokes an error in some DBMS (like postgres). Fixes #1375 Signed-off-by: Marco Nassabain --- lib/Db/Item.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/Db') diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 2ead77066..693b9417c 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -99,6 +99,13 @@ class Item extends Entity implements IAPI, \JsonSerializable public function __clone() { + $this->setId(null); + + /** + * Removes 'id' from updatedFields; this will avoid explicitly + * inserting the value NULL into the DB, and will instead allow a new + * id to be generated. + * */ $this->resetUpdatedFields(); $this->markFieldUpdated('contentHash'); $this->markFieldUpdated('guidHash'); -- cgit v1.2.3