Clean up error handling in processForm() to only check for errors when submitting an entry.

This enables the deletion or rejection of entries that produce errors. While we can't always
know why errors in objects make it this far we don't want to make it impossible to delete or
reject malformed entries.
This commit is contained in:
Chris Morgan
2007-08-05 20:14:07 +00:00
committed by WineHQ
parent 25c0346ce3
commit 242849cc04

View File

@@ -524,13 +524,20 @@ class ObjectManager
if(method_exists(new $this->sClass, "checkOutputEditorInput")) if(method_exists(new $this->sClass, "checkOutputEditorInput"))
{ {
$sErrors = $oObject->checkOutputEditorInput($aClean); $sErrors = $oObject->checkOutputEditorInput($aClean);
if($sErrors)
return $sErrors;
} }
// NOTE: we only check for errors when submitting
// because there is always the possibility that we can
// get into some error state but we don't want to be stuck, unable
// to delete an entry because of an error that we don't want to
// have to correct
switch($aClean['sSubmit']) switch($aClean['sSubmit'])
{ {
case "Submit": case "Submit":
// if we have errors, return them
if($sErrors)
return $sErrors;
// if we have a valid iId then we are displaying an existing entry // if we have a valid iId then we are displaying an existing entry
// otherwise we should create the entry in the 'else' case // otherwise we should create the entry in the 'else' case
if($this->iId) if($this->iId)
@@ -559,8 +566,16 @@ class ObjectManager
$oObject->reject(); $oObject->reject();
break; break;
case "Delete": case "Delete":
$this->delete_entry(); $this->delete_entry();
break;
default:
// shouldn't end up here, log the submit type that landed us here
error_log::log_error(ERROR_GENERAL, "processForm() received ".
"unknown aClean[sSubmit] of: ".$aClean['sSubmit']);
return false;
} }
/* Displaying the entire un-queued list for a class is not a good idea, /* Displaying the entire un-queued list for a class is not a good idea,
@@ -762,8 +777,10 @@ class ObjectManager
echo "</font><br />"; echo "</font><br />";
return TRUE; return TRUE;
} else } else
{
return FALSE; return FALSE;
} }
}
} }
class MultiPage class MultiPage