From 186c076f2e0cb14ba166a13c2caf58ad995cb5d8 Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Mon, 16 Sep 2013 13:24:13 +0200 Subject: [PATCH] Unset the primary key if a model is deleted (see #6162) --- system/docs/CHANGELOG.md | 3 +++ system/modules/core/library/Contao/Model.php | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/system/docs/CHANGELOG.md b/system/docs/CHANGELOG.md index 57cac6104a..cd1f1cc028 100644 --- a/system/docs/CHANGELOG.md +++ b/system/docs/CHANGELOG.md @@ -4,6 +4,9 @@ Contao Open Source CMS Changelog Version 3.1.3 (2013-XX-XX) -------------------------- +### Fixed +Unset the primary key if a model is deleted (see #6162). + ### Fixed Support `tel:` and `sms:` upon IDNA conversion (see #6148). diff --git a/system/modules/core/library/Contao/Model.php b/system/modules/core/library/Contao/Model.php index 8b226da514..f342d9f5f4 100644 --- a/system/modules/core/library/Contao/Model.php +++ b/system/modules/core/library/Contao/Model.php @@ -334,9 +334,12 @@ protected function postSave($intType) */ public function delete() { - return \Database::getInstance()->prepare("DELETE FROM " . static::$strTable . " WHERE " . static::$strPk . "=?") - ->execute($this->{static::$strPk}) - ->affectedRows; + $intAffected = \Database::getInstance()->prepare("DELETE FROM " . static::$strTable . " WHERE " . static::$strPk . "=?") + ->execute($this->{static::$strPk}) + ->affectedRows; + + $this->arrData[static::$strPk] = null; // see #6162 + return $intAffected; }