Skip to content

Commit

Permalink
handle corrupt saved searches
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 authored and cedric-anne committed Jan 11, 2024
1 parent aa750fb commit 46e3a34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ public function getMine(string $itemtype = null, bool $inverse = false, bool $en
} catch (\RuntimeException $e) {
ErrorHandler::getInstance()->handleException($e);
$search_data = false;
} catch (\Throwable $e) {
ErrorHandler::getInstance()->handleException($e);
$info_message = __s('A fatal error occurred while executing this saved search. It is not able to be used.');
$count = "<span class='ti ti-alert-triangle-filled' title='$info_message'></span>";
$data['_error'] = true;
}
if (isset($search_data['data']['totalcount'])) {
$count = $search_data['data']['totalcount'];
Expand Down
24 changes: 16 additions & 8 deletions templates/layout/parts/saved_searches_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@
{% for search in saved_searches %}
<div class="savedsearches-item grip-savedsearch list-group-item search-line d-flex align-items-center pe-1 {{ active == search['id'] ? 'active' : '' }}"
data-id="{{ search['id'] }}">
<a href="{{ 'SavedSearch'|itemtype_search_path }}?action=load&amp;id={{ search['id'] }}"
class="d-block saved-searches-link text-truncate">
{{ search['name']|verbatim_value }}
</a>
{% if search['_error'] is not defined or search['_error'] == false %}
<a href="{{ 'SavedSearch'|itemtype_search_path }}?action=load&amp;id={{ search['id'] }}"
class="d-block saved-searches-link text-truncate">
{{ search['name']|verbatim_value }}
</a>
{% else %}
<span class="d-block text-truncate">
{{ search['name']|verbatim_value }}
</span>
{% endif %}
<div class="{{ search['is_default'] > 0 ? '' : 'list-group-item-actions' }} ms-auto default-ctrl">
<i class="{{ search['is_default'] > 0 ? 'fas' : 'far' }} fa-star fa-xs mark-default me-1"
title="{{ search['is_default'] > 0 ? __('Default search') : __('mark as default') }}"
data-bs-toggle="tooltip" data-bs-placement="right"
role="button"></i>
{% if search['_error'] is not defined or search['_error'] == false %}
<i class="{{ search['is_default'] > 0 ? 'fas' : 'far' }} fa-star fa-xs mark-default me-1"
title="{{ search['is_default'] > 0 ? __('Default search') : __('mark as default') }}"
data-bs-toggle="tooltip" data-bs-placement="right"
role="button"></i>
{% endif %}
</div>
<div class="d-flex flex-nowrap align-items-center">
{% if search['is_private'] == 1 %}
Expand Down

0 comments on commit 46e3a34

Please sign in to comment.