summaryrefslogtreecommitdiffstats
path: root/lib/Db
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-06-12 23:51:53 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2021-06-16 11:31:11 +0200
commitb5186b01f1bc65ac8c4228e9e86cea2064883808 (patch)
treee252d884b5156c796fd1ca04fa657158adea72f2 /lib/Db
parent1d2287b10866d4f049266a41dcaa5a1c8e674e86 (diff)
🚑 Item: set id to null in clone function
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 <marco.nassabain@hotmail.com>
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/Item.php7
1 files changed, 7 insertions, 0 deletions
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');