From 2fd0883ea13fc69979d2cae128aca465478b6565 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Wed, 23 Sep 2009 00:02:50 +0000 Subject: [PATCH] BUGFIX: fixed ghost records existing on the live site when editing draft --- code/UserDefinedForm.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 1e5633b..f177222 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -107,6 +107,15 @@ class UserDefinedForm extends Page { * @return void */ public function doPublish() { + // remove fields on the live table which could have been orphaned. + $live = Versioned::get_by_stage("EditableFormField", "Live", "`EditableFormField`.ParentID = $this->ID"); + if($live) { + foreach($live as $field) { + $field->deleteFromStage('Live'); + } + } + + // publish the draft pages if($this->Fields()) { foreach($this->Fields() as $field) { $field->publish('Stage', 'Live');