mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Throw an exception if you try an delete an unsaved or already-deleted record
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@106078 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7cc9709123
commit
e1753a35e5
@ -1122,6 +1122,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
user_error("$this->class has a broken onBeforeDelete() function. Make sure that you call parent::onBeforeDelete().", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Deleting a record without an ID shouldn't do anything
|
||||
if(!$this->ID) throw new Exception("DataObject::delete() called on a DataObject without an ID");
|
||||
|
||||
foreach($this->getClassAncestry() as $ancestor) {
|
||||
if(self::has_own_table($ancestor)) {
|
||||
$sql = new SQLQuery();
|
||||
|
Loading…
Reference in New Issue
Block a user