From ac63992efa99e7100fa48ab9052e4a2a9d3f80f2 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Sun, 21 Jun 2020 19:08:06 -0500 Subject: [PATCH] Added BulkActionException to allow clean error feedback from bulk actions --- ext/bulk_actions/main.php | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index ba613be3..35455f48 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -1,5 +1,8 @@ yield_items($data); + } + } elseif (isset($_POST['bulk_query']) && $_POST['bulk_query'] != "") { + $query = $_POST['bulk_query']; + if ($query != null && $query != "") { + $items = $this->yield_search_results($query); + } + } else { + throw new BulkActionException("No ids selected and no query present, cannot perform bulk operation on entire collection"); } - if (is_array($data)&&!empty($data)) { - $items = $this->yield_items($data); - } - } elseif (isset($_POST['bulk_query']) && $_POST['bulk_query'] != "") { - $query = $_POST['bulk_query']; - if ($query != null && $query != "") { - $items = $this->yield_search_results($query); - } - } else { - throw new SCoreException("No ids selected and no query present, cannot perform bulk operation on entire collection"); - } - $bae = new BulkActionEvent($action, $items); + $bae = new BulkActionEvent($action, $items); - if (is_iterable($items)) { - send_event($bae); + if (is_iterable($items)) { + send_event($bae); + } + } catch (BulkActionException $e) { + log_error(BulkActionsInfo::KEY, $e->getMessage(), $e->getMessage()); } if ($bae->redirect) {