MINOR Merged from trunk

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@77992 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-05-27 21:30:28 +00:00 committed by Sam Minnee
parent 233f5e79e9
commit d663843020

View File

@ -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]))