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 (from r106078)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112513 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b839ab2b9f
commit
ee0d4c5197
@ -1173,6 +1173,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