From d66384302050359f94b7be0da17b841872187486 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 27 May 2009 21:30:28 +0000 Subject: [PATCH] MINOR Merged from trunk git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@77992 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/WidgetAreaEditor.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/WidgetAreaEditor.php b/code/WidgetAreaEditor.php index a7c905e5..a083bc5e 100644 --- a/code/WidgetAreaEditor.php +++ b/code/WidgetAreaEditor.php @@ -64,8 +64,20 @@ class WidgetAreaEditor extends FormField { foreach(array_keys( $_REQUEST['Widget'] ) as $newWidgetID ) { $newWidgetData = $_REQUEST['Widget'][$newWidgetID]; - // `ParentID`=0 is for the new page - $widget = DataObject::get_one( 'Widget', "(`ParentID`='{$record->$name()->ID}' OR `ParentID`=0) AND `Widget`.`ID`='$newWidgetID'" ); + // Sometimes the id is "new-1" or similar, ensure this doesn't get into the query + if(!is_numeric($newWidgetID)) { + $newWidgetID = 0; + } + + // \"ParentID\" = '0' is for the new page + $widget = DataObject::get_one( + 'Widget', + sprintf( + '(`ParentID` = %d OR `ParentID` = 0) AND `Widget`.`ID` = %d', + $record->$name()->ID, + (int)$newWidgetID + ) + ); // check if we are updating an existing widget if($widget && isset($missingWidgets[$widget->ID]))