diff --git a/src/SavedSearch.php b/src/SavedSearch.php index 1c2775719db..cd507859a38 100644 --- a/src/SavedSearch.php +++ b/src/SavedSearch.php @@ -861,30 +861,37 @@ public function getMine(string $itemtype = null, bool $inverse = false, bool $en $iterator = $DB->request($criteria); foreach ($iterator as $data) { + $error = false; + if ($_SESSION['glpishow_count_on_tabs']) { $this->fields = $data; $count = null; + $search_data = null; try { $search_data = $this->execute(false, $enable_partial_warnings); - } catch (\RuntimeException $e) { + } catch (\Throwable $e) { ErrorHandler::getInstance()->handleException($e); - $search_data = false; + $error = true; } - if (isset($search_data['data']['totalcount'])) { + + if ($error) { + $info_message = __s('A fatal error occurred while executing this saved search. It is not able to be used.'); + $count = ""; + } elseif (isset($search_data['data']['totalcount'])) { $count = $search_data['data']['totalcount']; } else { $info_message = ($this->fields['do_count'] == self::COUNT_NO) ? __s('Count for this saved search has been disabled.') : __s('Counting this saved search would take too long, it has been skipped.'); - if ($count === null) { - //no count, just inform the user - $count = ""; - } + // no count, just inform the user + $count = ""; } $data['count'] = $count; } + $data['_error'] = $error; + $searches[$data['id']] = $data; } diff --git a/templates/layout/parts/saved_searches_list.html.twig b/templates/layout/parts/saved_searches_list.html.twig index 4f5f7c77edc..62c55e54705 100644 --- a/templates/layout/parts/saved_searches_list.html.twig +++ b/templates/layout/parts/saved_searches_list.html.twig @@ -41,15 +41,23 @@ {% for search in saved_searches %}
- - {{ search['name']|verbatim_value }} - + {% if not search['_error'] %} + + {{ search['name']|verbatim_value }} + + {% else %} + + {{ search['name']|verbatim_value }} + + {% endif %}
- + {% if not search['_error'] %} + + {% endif %}
{% if search['is_private'] == 1 %}