From 809183716a3a14af004672c9d921ff23d17d5f62 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 12 Aug 2021 13:42:36 -0400 Subject: [PATCH] clean up code logic so that if we are executing an unchanged filter we don't do the unecessary save. --- web/includes/actions/filter.php | 37 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/web/includes/actions/filter.php b/web/includes/actions/filter.php index 4516fbc50..058a004ed 100644 --- a/web/includes/actions/filter.php +++ b/web/includes/actions/filter.php @@ -66,30 +66,23 @@ if (isset($_REQUEST['object']) and ($_REQUEST['object'] == 'filter')) { $changes = $filter->changes($_REQUEST['filter']); ZM\Debug('Changes: ' . print_r($changes, true)); - if ($filter->Id() and ($action == 'Save')) { - if ($filter->Background()) $filter->control('stop'); - if (!$filter->save($changes)) { - $error_message = $filter->get_last_error(); - return; - } - } else { - if ($action == 'execute') { + if (count($changes)) { + if ($filter->Id() and ($action == 'Save') and $filter->Background()) { + $filter->control('stop'); + } else if ($action == 'execute') { # If there are changes use a temp filter to do the execute - if (count($changes)) { - $filter->Name('_TempFilter'.time()); - $filter->Id(null); - } + $filter->Name('_TempFilter'.time()); + $filter->Id(null); } else if ($action == 'SaveAs') { - $filter->Id(null); - } - if (!$filter->save($changes)) { - $error_message = $filter->get_last_error(); - return; - } - - // We update the request id so that the newly saved filter is auto-selected - $_REQUEST['Id'] = $filter->Id(); - } + $filter->Id(null); + } + if (!$filter->save($changes)) { + $error_message = $filter->get_last_error(); + return; + } + // We update the request id so that the newly saved filter is auto-selected + $_REQUEST['Id'] = $filter->Id(); + } # end if changes if ($action == 'execute') { $filter->execute();