clean up code logic so that if we are executing an unchanged filter we don't do the unecessary save.
This commit is contained in:
parent
248ca9a5f9
commit
a311455526
|
@ -66,30 +66,23 @@ if (isset($_REQUEST['object']) and ($_REQUEST['object'] == 'filter')) {
|
||||||
$changes = $filter->changes($_REQUEST['filter']);
|
$changes = $filter->changes($_REQUEST['filter']);
|
||||||
ZM\Debug('Changes: ' . print_r($changes, true));
|
ZM\Debug('Changes: ' . print_r($changes, true));
|
||||||
|
|
||||||
if ($filter->Id() and ($action == 'Save')) {
|
if (count($changes)) {
|
||||||
if ($filter->Background()) $filter->control('stop');
|
if ($filter->Id() and ($action == 'Save') and $filter->Background()) {
|
||||||
if (!$filter->save($changes)) {
|
$filter->control('stop');
|
||||||
$error_message = $filter->get_last_error();
|
} else if ($action == 'execute') {
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($action == 'execute') {
|
|
||||||
# If there are changes use a temp filter to do the execute
|
# If there are changes use a temp filter to do the execute
|
||||||
if (count($changes)) {
|
$filter->Name('_TempFilter'.time());
|
||||||
$filter->Name('_TempFilter'.time());
|
$filter->Id(null);
|
||||||
$filter->Id(null);
|
|
||||||
}
|
|
||||||
} else if ($action == 'SaveAs') {
|
} else if ($action == 'SaveAs') {
|
||||||
$filter->Id(null);
|
$filter->Id(null);
|
||||||
}
|
}
|
||||||
if (!$filter->save($changes)) {
|
if (!$filter->save($changes)) {
|
||||||
$error_message = $filter->get_last_error();
|
$error_message = $filter->get_last_error();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// We update the request id so that the newly saved filter is auto-selected
|
||||||
// We update the request id so that the newly saved filter is auto-selected
|
$_REQUEST['Id'] = $filter->Id();
|
||||||
$_REQUEST['Id'] = $filter->Id();
|
} # end if changes
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'execute') {
|
if ($action == 'execute') {
|
||||||
$filter->execute();
|
$filter->execute();
|
||||||
|
|
Loading…
Reference in New Issue