From 1c395037c3f75a434301cb5a4bbb1d4574b45733 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 8 Mar 2016 22:24:53 +0100 Subject: [PATCH] DbObject.php: forget autoinc on clone --- library/Director/Data/Db/DbObject.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index 857cefaf..f940e108 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -517,6 +517,15 @@ abstract class DbObject return null; } + protected function forgetAutoincId() + { + if (isset($this->properties[$this->autoincKeyName])) { + $this->properties[$this->autoincKeyName] = null; + } + + return $this; + } + /** * Liefert das benutzte Datenbank-Handle * @@ -876,7 +885,7 @@ abstract class DbObject public function __clone() { $this->onClone(); - $this->autoincKeyName = null; + $this->forgetAutoincId(); $this->loadedFromDb = false; $this->hasBeenModified = true; }