23 August 2010 at 4:02am
(Last edited: 23 August 2010 4:35am),
after update to 2.4.1 i can't delete Dataobjects on all Stages from my Frontend-Forms (it works in the admin). The entry is only deleted in the _Live-Table and keeps it in the _Versions-Table and Stage-Table.
23 August 2010 at 9:14am
Probably because $invitation is a single dataobject and delete() only deletes the object in question and not any of its staged components. I think the easiest way is to call the deleteFromStage() function on the object to delete from each.
i'm a little bit confused, because i looked in the docs http://api.silverstripe.org/2.4/sapphire/model/DataObject.html#methoddelete and read:
void delete( )
Delete this data object.
$this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted.
i try also "DataObjcect::get("Invitation", … )->delete(); but it only removes the data from the _Live-Table.
Something is wrong. The Delete-Method or the Docs.
10 September 2010 at 4:12pm
delete it on both stages but keeps the Versions.
Yes it won't delete versions as delete() may imply you want to revert to it (versions is like a history). Not sure if the ORM has any functionality for that (eg try allVersions()) but you could always use good old plain Database queries!
DB::query("DELETE FROM Table_versions WHERE RecordID = '$invitation->ID'");