Skip to content

Commit

Permalink
Unset the primary key if a model is deleted (see contao#6162)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer authored and ralfhartmann committed Oct 2, 2013
1 parent d2a37bc commit 186c076
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
9 changes: 6 additions & 3 deletions system/modules/core/library/Contao/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 186c076

Please sign in to comment.