From dd4c211faffba6a109bb176df4b6f04d073daed5 Mon Sep 17 00:00:00 2001 From: kouralex <1723419+kouralex@users.noreply.github.com> Date: Fri, 17 Jul 2020 01:02:57 +0300 Subject: [PATCH 1/9] fixes fore failing vocabulary/global search; fixes erroring ajax search queries; fixes waypoint system used in search; added checks for various easyrdf http client errors (cherry picked from commit 9f762ff14cdd17b92dc944dab9a1c0176fdc6efb) --- controller/WebController.php | 41 +++++++++++++++++++++++++++++----- model/DataObject.php | 25 +++++++++++++++------ model/Model.php | 29 ++++++++++++++++++------ resource/css/styles.css | 15 +++++++++++++ resource/js/docready.js | 25 +++++++++++++++++---- resource/js/scripts.js | 3 ++- view/search-result.twig | 10 ++++++++- view/vocab-search-listing.twig | 4 ++-- 8 files changed, 124 insertions(+), 28 deletions(-) diff --git a/controller/WebController.php b/controller/WebController.php index ce1974948..731d4fdea 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -329,23 +329,47 @@ public function invokeGlobalSearch($request) $vocabObjects = array(); if ($vocids) { foreach($vocids as $vocid) { - $vocabObjects[] = $this->model->getVocabulary($vocid); + try { + $vocabObjects[] = $this->model->getVocabulary($vocid); + } catch (Exception $e) { + // skip vocabularies not found in configuration + // please note that this may result in global search + // NB: should not happen in normal UI interaction + } } } $parameters->setVocabularies($vocabObjects); + $nondefaultEndpointVocs = array(); + + if (sizeOf($vocabObjects) != 1) { + // global search, either from all (sizeOf($vocabObjects) == 0) or from selected ones + if (sizeOf($vocabObjects) == 0) { + $vocabObjects = $this->model->getVocabularies(); + } + $defaultEndpoint = $this->model->getConfig()->getDefaultEndpoint(); + foreach($vocabObjects as $voc) { + if ($voc->getEndpoint() !== $defaultEndpoint) { + $nondefaultEndpointVocs[] = $voc; + } + } + } + + $counts = null; + $searchResults = null; + $errored = false; + try { $countAndResults = $this->model->searchConceptsAndInfo($parameters); + $counts = $countAndResults['count']; + $searchResults = $countAndResults['results']; } catch (Exception $e) { - header("HTTP/1.0 404 Not Found"); + $errored = true; + header("HTTP/1.0 500 Internal Server Error"); if ($this->model->getConfig()->getLogCaughtExceptions()) { error_log('Caught exception: ' . $e->getMessage()); } - $this->invokeGenericErrorPage($request, $e->getMessage()); - return; } - $counts = $countAndResults['count']; - $searchResults = $countAndResults['results']; $vocabList = $this->model->getVocabularyList(); $sortedVocabs = $this->model->getVocabularyList(false, true); $langList = $this->model->getLanguages($lang); @@ -357,6 +381,8 @@ public function invokeGlobalSearch($request) 'search_results' => $searchResults, 'rest' => $parameters->getOffset()>0, 'global_search' => true, + 'search_failed' => $errored, + 'skipped_vocabs' => $nondefaultEndpointVocs, 'term' => $request->getQueryParamRaw('q'), 'lang_list' => $langList, 'vocabs' => str_replace(' ', '+', $vocabs), @@ -375,6 +401,7 @@ public function invokeVocabularySearch($request) $template = $this->twig->loadTemplate('vocab-search-listing.twig'); $this->setLanguageProperties($request->getLang()); $vocab = $request->getVocab(); + $searchResults = null; try { $vocabTypes = $this->model->getTypes($request->getVocabid(), $request->getLang()); } catch (Exception $e) { @@ -388,6 +415,7 @@ public function invokeVocabularySearch($request) 'languages' => $this->languages, 'vocab' => $vocab, 'request' => $request, + 'search_results' => $searchResults )); return; @@ -411,6 +439,7 @@ public function invokeVocabularySearch($request) 'languages' => $this->languages, 'vocab' => $vocab, 'term' => $request->getQueryParam('q'), + 'search_results' => $searchResults )); return; } diff --git a/model/DataObject.php b/model/DataObject.php index a1359758d..2865cbcc4 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -46,10 +46,15 @@ public function __construct($model, $resource) protected function getExternalLabel($exvoc, $exuri, $lang) { if ($exvoc) { - $exsparql = $exvoc->getSparql(); - $results = $exsparql->queryLabel($exuri, $lang); - - return isset($results[$lang]) ? $results[$lang] : null; + try { + $exsparql = $exvoc->getSparql(); + $results = $exsparql->queryLabel($exuri, $lang); + return isset($results[$lang]) ? $results[$lang] : null; + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { + if ($this->model->getConfig()->getLogCaughtExceptions()) { + error_log('Caught exception: ' . $e->getMessage()); + } + } } return null; } @@ -63,9 +68,15 @@ protected function getExternalLabel($exvoc, $exuri, $lang) protected function getExternalNotation($exvoc, $exuri) { if ($exvoc) { - $exsparql = $exvoc->getSparql(); - $results = $exsparql->queryNotation($exuri); - return isset($results) ? $results : null; + try { + $exsparql = $exvoc->getSparql(); + $results = $exsparql->queryNotation($exuri); + return isset($results) ? $results : null; + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { + if ($this->model->getConfig()->getLogCaughtExceptions()) { + error_log('Caught exception: ' . $e->getMessage()); + } + } } return null; } diff --git a/model/Model.php b/model/Model.php index 9b6b6d819..a4ed6b323 100644 --- a/model/Model.php +++ b/model/Model.php @@ -470,11 +470,18 @@ private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null) if($preferredVocabId != null) { foreach ($vocabs as $vocab) { if($vocab->getId() == $preferredVocabId) { - // double check that a label exists in the preferred vocabulary - if ($vocab->getConceptLabel($uri, null) !== null) { - return $vocab; - } else { - // not found in preferred vocabulary, fall back to next method + try { + // double check that a label exists in the preferred vocabulary + if ($vocab->getConceptLabel($uri, null) !== null) { + return $vocab; + } else { + // not found in preferred vocabulary, fall back to next method + break; + } + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { + if ($this->getConfig()->getLogCaughtExceptions()) { + error_log('Caught exception: ' . $e->getMessage()); + } break; } } @@ -483,8 +490,16 @@ private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null) // no preferred vocabulary, or it was not found, search in which vocabulary the concept has a label foreach ($vocabs as $vocab) { - if ($vocab->getConceptLabel($uri, null) !== null) - return $vocab; + try { + if ($vocab->getConceptLabel($uri, null) !== null) { + return $vocab; + } + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { + if ($this->getConfig()->getLogCaughtExceptions()) { + error_log('Caught exception: ' . $e->getMessage()); + } + break; + } } // if the URI couldn't be found, fall back to the first vocabulary diff --git a/resource/css/styles.css b/resource/css/styles.css index aeaf2fc89..ffdcb4a2e 100644 --- a/resource/css/styles.css +++ b/resource/css/styles.css @@ -1068,6 +1068,21 @@ div#sidebar-grey > div > div > form.search-options { top: 10px; } +.search-result-listing .alert .btn-default { + position: unset; + vertical-align: unset; + margin-left: 15px; + font-size: 18px; +} + +.alert h4, .alert h3 { + display: inline; +} + +.search-result-listing .alert-warning h4 { + display: block; +} + .search-options .mCSB_container > li > a > .radio { margin: 0; padding-left: 25px; diff --git a/resource/js/docready.js b/resource/js/docready.js index 03e3d75b4..6d82341f6 100644 --- a/resource/js/docready.js +++ b/resource/js/docready.js @@ -844,7 +844,7 @@ $(function() { // DOCUMENT READY $('.search-result-listing').append($ready); } else { - $trigger.waypoint(function() { waypointCallback(); }, options); + $trigger.waypoint(function() { waypointCallback(this); }, options); } } @@ -894,9 +894,13 @@ $(function() { // DOCUMENT READY changeOffset += 200; } - function waypointCallback() { + function waypointCallback(waypoint) { + if ($('.search-result-listing > p .spinner,.search-result-listing .alert-danger').length > 0) { + return false; + } var number_of_hits = $(".search-result").length; - if (number_of_hits < parseInt($('.search-count p').text().substr(0, $('.search-count p').text().indexOf(' ')), 10)) { $('.search-result-listing').append($loading); + if (number_of_hits < parseInt($('.search-count p').text().substr(0, $('.search-count p').text().indexOf(' ')), 10)) { + $('.search-result-listing').append($loading); var typeLimit = $('#type-limit').val(); var schemeLimit = $('#scheme-limit').val(); var groupLimit = $('#group-limit').val(); @@ -917,7 +921,20 @@ $(function() { // DOCUMENT READY $('.search-result-listing').append($ready); return false; } - $('.search-result:nth-last-of-type(4)').waypoint(function() { waypointCallback(); }, options ); + waypoint.destroy(); + $('.search-result:nth-last-of-type(4)').waypoint(function() { waypointCallback(this); }, options ); + }, + error: function(jqXHR, textStatus, errorThrown) { + $loading.detach(); + var $failedSearch = $('

Error: Loading for more items failed!

'); + var $retryButton = $(''); + $retryButton.on('click', function () { + $failedSearch.remove(); + waypointCallback(waypoint); + return false; + }); + $failedSearch.append($retryButton) + $('.search-result-listing').append($failedSearch); } }); } diff --git a/resource/js/scripts.js b/resource/js/scripts.js index 6ec85e381..f405a91ee 100644 --- a/resource/js/scripts.js +++ b/resource/js/scripts.js @@ -210,7 +210,8 @@ function loadLimitedResults(parameters) { clearResultsAndAddSpinner(); $.ajax({ data: parameters, - success : function(data) { + complete : function(jqXHR, textStatus) { + var data = jqXHR.responseText; var response = $('.search-result-listing', data).html(); if (window.history.pushState) { window.history.pushState({url: this.url}, '', this.url); } $('.search-result-listing').append(response); diff --git a/view/search-result.twig b/view/search-result.twig index 676b36f35..a2530d9c1 100644 --- a/view/search-result.twig +++ b/view/search-result.twig @@ -2,7 +2,15 @@

{% trans %}{{ search_count }} results for '{{ term }}'{% endtrans %}{% if limit_type %}, {% trans "limited to type" %} '{% for type in limit_type %}{{ type }}{% if loop.last == false %}, {% endif %}{% endfor %}'{% endif %}{% if limit_parent %}, {% trans "limited to parent" %} '{{ limit_parent }}'{% endif %}{% if limit_group %}, {% trans "limited to group" %} '{{ limit_group }}'{% endif %}{% if limit_scheme %}, {% trans "limited to scheme" %} '{% for scheme in limit_scheme %}{{ scheme }}{% if loop.last == false %}, {% endif %}{% endfor %}'{% endif %}

{% if limit_type or limit_parent or limit_group or limit_scheme %}{% endif %} {% endif %} -{% if search_results is defined and search_results|length == 0 %}

{% trans 'The search provided no results.' %}

{% endif %} +{% if global_search and not search_failed and skipped_vocabs|length > 0 %} +
+{% for voc in skipped_vocabs %} +{% set vocTitle = voc.title %} +

{% trans %}Warning: Skipped searching from '{{vocTitle}}' vocabulary!{% endtrans %}

+{% endfor %} +
+{% endif %} +{% if search_results is not null and search_results|length == 0 %}

{% trans 'The search provided no results.' %}

{% endif %} {% for concept in search_results %} {# loop through the hits #}
{% spaceless %} diff --git a/view/vocab-search-listing.twig b/view/vocab-search-listing.twig index 95d9b2902..3be9b7cd2 100644 --- a/view/vocab-search-listing.twig +++ b/view/vocab-search-listing.twig @@ -6,9 +6,9 @@

{% trans "Search results" %}

{% include 'search-result.twig' %} - {% if search_results is not defined and not global_search %} + {% if search_results is null %}
- {% if request.vocabid == 'null' %} + {% if request.vocabid == 'null' and not global_search %}

{% trans %}Error: Requested vocabulary not found!{% endtrans %}

{% else %}

{% trans %}Error: Search failed!{% endtrans %}

From 99d8194c85642c5cead56f912c9582bd71163227 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 11:44:58 +0300 Subject: [PATCH 2/9] catch ValueError instead of Exception, since getVocabulary throws it nowadays --- controller/WebController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/WebController.php b/controller/WebController.php index 731d4fdea..0f13bc105 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -331,7 +331,7 @@ public function invokeGlobalSearch($request) foreach($vocids as $vocid) { try { $vocabObjects[] = $this->model->getVocabulary($vocid); - } catch (Exception $e) { + } catch (ValueError $e) { // skip vocabularies not found in configuration // please note that this may result in global search // NB: should not happen in normal UI interaction From 2d5f1ee3f6f7c7ca7151bca3bf8dd046cad83942 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 11:49:25 +0300 Subject: [PATCH 3/9] fail fast with an error page instead of skipping unknown vocabularies --- controller/WebController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/controller/WebController.php b/controller/WebController.php index 0f13bc105..8a7b07861 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -332,9 +332,12 @@ public function invokeGlobalSearch($request) try { $vocabObjects[] = $this->model->getVocabulary($vocid); } catch (ValueError $e) { - // skip vocabularies not found in configuration - // please note that this may result in global search - // NB: should not happen in normal UI interaction + // fail fast with an error page if the vocabulary cannot be found + if ($this->model->getConfig()->getLogCaughtExceptions()) { + error_log('Caught exception: ' . $e->getMessage()); + } + header("HTTP/1.0 400 Bad Request"); + return $this->invokeGenericErrorPage($request, $e->getMessage()); } } } From 21ee3c8666a46ae99573352012ef28705e54d675 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 12:39:30 +0300 Subject: [PATCH 4/9] Minimal CSS styling for retry button on search result page --- resource/css/styles.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resource/css/styles.css b/resource/css/styles.css index ffdcb4a2e..8dc85da13 100644 --- a/resource/css/styles.css +++ b/resource/css/styles.css @@ -522,6 +522,10 @@ ul.dropdown-menu > li:last-child > input { margin: 10px 0px; } +.search-result-listing > .alert > .btn-default { + border-radius: 0; +} + .search-result-listing .search-count { text-align: left; margin-left: 15px; From 22f57ff6cc2f652d94bf8a9a7092aa229bfbe277 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 12:46:35 +0300 Subject: [PATCH 5/9] Add translations (fi/sv/en) for error message and button shown on search result page --- resource/js/docready.js | 4 ++-- .../translations/en/LC_MESSAGES/skosmos.mo | Bin 13734 -> 13846 bytes .../translations/fi/LC_MESSAGES/skosmos.mo | Bin 14023 -> 14152 bytes resource/translations/skosmos_en.po | 6 ++++++ resource/translations/skosmos_fi.po | 6 ++++++ resource/translations/skosmos_sv.po | 6 ++++++ .../translations/sv/LC_MESSAGES/skosmos.mo | Bin 13918 -> 14044 bytes view/scripts.twig | 2 ++ 8 files changed, 22 insertions(+), 2 deletions(-) diff --git a/resource/js/docready.js b/resource/js/docready.js index 6d82341f6..3362aaa49 100644 --- a/resource/js/docready.js +++ b/resource/js/docready.js @@ -926,8 +926,8 @@ $(function() { // DOCUMENT READY }, error: function(jqXHR, textStatus, errorThrown) { $loading.detach(); - var $failedSearch = $('

Error: Loading for more items failed!

'); - var $retryButton = $(''); + var $failedSearch = $('

' + loading_failed_text + '

'); + var $retryButton = $(''); $retryButton.on('click', function () { $failedSearch.remove(); waypointCallback(waypoint); diff --git a/resource/translations/en/LC_MESSAGES/skosmos.mo b/resource/translations/en/LC_MESSAGES/skosmos.mo index f727641b3f341ee656f4c551299edb9210b74a68..2b920a38fded63724c452f1a5907006b43aa7106 100644 GIT binary patch del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$^3ZicQ}UJ zL8{0Qa)dM^8_2iFugN6hHaFq&|8bOlN**V>FCXO@qU^Jfp8t8UkobD^A(yu06jqU5 z@qiE8fmrT>)#SINfqa9kAPb8z{8%o<{XEY4$cy+6q Y(ss2C-FnPwS~IlcO$~qPbz{r_1Dvp)q5uE@ diff --git a/resource/translations/fi/LC_MESSAGES/skosmos.mo b/resource/translations/fi/LC_MESSAGES/skosmos.mo index 3dd9577cc896a78d190636a821b1c7f530f6ccbb..f6f23cc7e794d3bb0abaaf603b37fe7e18fdc888 100644 GIT binary patch delta 4530 zcmYk<2~ZbR0LSsCD5xlhARb8mQxQ=}QSpw<)T~St4?OZf`HK{aTvm9j=22#)iHfC$ z_mzeD_ek-G@G3){n$pSg7^<19@hGQbtg-Kpea^Jw@Bi7i`}XbI_uejbdfJ)k&XtC> zRvESnq&ZpVZ%m^a>^IO+V`hXJ(+YDi5m%ufp2gaD9_!)P*aWX(UHlsxq8~rO7=h8) z2J7G;q@H6&xI1P725=%112G3%;vA$cvjM|!FNWYLRK1HBiB5R453x^_-Ty5ai|OOF$U*jBJRXEylRivr*b>WU9baAK#k-w zRC~p!8}34lj1M(shtPS5ofGV6?yFEY)MID_8laviiXUB=h%67&3pFBrkxNWE@(gAc z2H|qljZ18KFEWUx9JQ>z#{O8sQT1k^)_{Y0pe3jd6kE6Jgen|FHCT>nu+o+97WyeBC6sItZq2UovLta z8`P6`M?L94TONk$;AGT;WT8f|5LNG0TV8=-djCt<(FH!#jgFw!L?!A5S5XbzLN)jg zs)O}-b#y)o^~CY0dVNvXC)@LB)*Mv5`L?`TWxfB~*inOJ_QW}zpnL_@;P3XlmcBX| zhU!Rb)D(2G$CIqd$fv zn8%&VXw><~Q0E7uMr0DIqq(S#EI>{1JGQ(Jb^db?qXU@i@M=5WZ9T?sQVno7`))v z1An20FeuvXSxeLt^guN{3fp4_>cS%ApDE)`x_itO-7X-KBndS{qftH2w&xvWkjzrl(C$G$EJs~;5;aoSP*Zpd{jp}O zJ3@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m3LD>{WCv97gXu89j$SAeRNkY=lzuzJ5sC!WiUyDom%~gBGC|ZoqWK=v*C+oHn0WSk#^_^mZR5I#Qj^*ML7z+elq6y{y$8?2hBqtumY`M3tHiJw1NBL z`S;KspF*$u8ofV@cgp*VqNV6{ed7M@asO_#zDke#{yz~iWj_sj>I9fAs?Vq z@Q-->Y&45kgik;yM6c_LKHz$EN{66pWOQ^Q`kWba2===OOI^^%59rz^rFZ9!W9_?`ky>Zp&A$f44Y!*Iq3C^(IKwJ>u@*P!GEI- zZ@|LJ^!@KZ!3w*e5556M;7D|2Uc|n*2VEQgK`Xd`KCn66*LLWGyW^uc7_IjZ+Ogy4 z$ecz;>O2v z|DL$NAHD8#5%YU z9l5ROVy?y`c(9D|&!X^bm*m2A$n=Lz=u{j*A9M=G;iuRe2X#$GU@kUfe=+(#uSFZO z3z?m86#ej=i^p@i@kX)V3hUu5-57s|Xm~s^9-Z@rXwTQ76>mo?`cpjqG1~Ai(Vm@0 z-}7*F(y$`5=k3vWS(>I%22MMR*Yztk9x7>FGe^QDFqy(0SAyw~$T5wQy;>oQbWE=7LW(Yt;Fpx`60Q*9k!KZ8foSZ z+b%M~`5!`lMkbRCvX0zEeoPvWDWsgNCX>i*79jcSgy-&4D0O-V(g{{s!)pF#it diff --git a/view/scripts.twig b/view/scripts.twig index 1a980a287..0f62b0efe 100644 --- a/view/scripts.twig +++ b/view/scripts.twig @@ -2,6 +2,8 @@ var noResultsTranslation = "{% trans %}No results{% endtrans %}"; var loading_text = "{% trans %}Loading more items{% endtrans %}"; +var loading_failed_text = "{% trans %}Error: Loading more items failed!{% endtrans %}"; +var loading_retry_text = "{% trans %}Retry{% endtrans %}"; var jstree_loading = "{% trans %}Loading{% endtrans %} ..."; var results_disp = "{% trans %}All %d results displayed{% endtrans %}"; var all_vocabs = "{% trans %}from all{% endtrans %}"; From 189fe980b63d5e4f22645aad00aefe94cfd65fb5 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 12:50:08 +0300 Subject: [PATCH 6/9] Avoid using return value from method that doesn't return anything (bug found by sonarqube) --- controller/WebController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/WebController.php b/controller/WebController.php index 8a7b07861..ed0ea6f22 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -337,7 +337,8 @@ public function invokeGlobalSearch($request) error_log('Caught exception: ' . $e->getMessage()); } header("HTTP/1.0 400 Bad Request"); - return $this->invokeGenericErrorPage($request, $e->getMessage()); + $this->invokeGenericErrorPage($request, $e->getMessage()); + return; } } } From 14eac78e82cb3434df8d911d52386c28df26e597 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 12:52:27 +0300 Subject: [PATCH 7/9] use empty() instead of sizeof(xxx) == 0 which is clearer (bug found by sonarqube) --- controller/WebController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/WebController.php b/controller/WebController.php index ed0ea6f22..d3725a086 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -348,7 +348,7 @@ public function invokeGlobalSearch($request) if (sizeOf($vocabObjects) != 1) { // global search, either from all (sizeOf($vocabObjects) == 0) or from selected ones - if (sizeOf($vocabObjects) == 0) { + if (empty($vocabObjects)) { $vocabObjects = $this->model->getVocabularies(); } $defaultEndpoint = $this->model->getConfig()->getDefaultEndpoint(); From c7771867e050ce7b4ef3d125b84f3e068702a574 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 15:28:51 +0300 Subject: [PATCH 8/9] Adjust for change to ValueError --- model/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/Model.php b/model/Model.php index a4ed6b323..5cc570140 100644 --- a/model/Model.php +++ b/model/Model.php @@ -245,7 +245,7 @@ public function searchConcepts($params) try { $hitvoc = $this->getVocabularyByGraph($hit['graph']); $hit['vocab'] = $hitvoc->getId(); - } catch (Exception $e) { + } catch (ValueError $e) { trigger_error($e->getMessage(), E_USER_WARNING); $hitvoc = null; $hit['vocab'] = "???"; @@ -255,7 +255,7 @@ public function searchConcepts($params) $hit['voc'] = $hitvoc; - if (!$hitvoc->containsURI($hit['uri'])) { + if ($hitvoc === null || !$hitvoc->containsURI($hit['uri'])) { // if uri is a external vocab uri that is included in the current vocab $realvoc = $this->guessVocabularyFromURI($hit['uri'], $voc !== null ? $voc->getId() : null); if ($realvoc !== $hitvoc) { From ee5e40f4b72b6d0d59f3ad145cddd12b5b256e8d Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 9 Sep 2021 16:03:57 +0300 Subject: [PATCH 9/9] Remove warning message about skipped vocabs (too obtrusive and the user can't do anything about it) --- controller/WebController.php | 16 ---------------- view/search-result.twig | 8 -------- 2 files changed, 24 deletions(-) diff --git a/controller/WebController.php b/controller/WebController.php index d3725a086..f2034280d 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -344,21 +344,6 @@ public function invokeGlobalSearch($request) } $parameters->setVocabularies($vocabObjects); - $nondefaultEndpointVocs = array(); - - if (sizeOf($vocabObjects) != 1) { - // global search, either from all (sizeOf($vocabObjects) == 0) or from selected ones - if (empty($vocabObjects)) { - $vocabObjects = $this->model->getVocabularies(); - } - $defaultEndpoint = $this->model->getConfig()->getDefaultEndpoint(); - foreach($vocabObjects as $voc) { - if ($voc->getEndpoint() !== $defaultEndpoint) { - $nondefaultEndpointVocs[] = $voc; - } - } - } - $counts = null; $searchResults = null; $errored = false; @@ -386,7 +371,6 @@ public function invokeGlobalSearch($request) 'rest' => $parameters->getOffset()>0, 'global_search' => true, 'search_failed' => $errored, - 'skipped_vocabs' => $nondefaultEndpointVocs, 'term' => $request->getQueryParamRaw('q'), 'lang_list' => $langList, 'vocabs' => str_replace(' ', '+', $vocabs), diff --git a/view/search-result.twig b/view/search-result.twig index a2530d9c1..4e1d521b5 100644 --- a/view/search-result.twig +++ b/view/search-result.twig @@ -2,14 +2,6 @@

{% trans %}{{ search_count }} results for '{{ term }}'{% endtrans %}{% if limit_type %}, {% trans "limited to type" %} '{% for type in limit_type %}{{ type }}{% if loop.last == false %}, {% endif %}{% endfor %}'{% endif %}{% if limit_parent %}, {% trans "limited to parent" %} '{{ limit_parent }}'{% endif %}{% if limit_group %}, {% trans "limited to group" %} '{{ limit_group }}'{% endif %}{% if limit_scheme %}, {% trans "limited to scheme" %} '{% for scheme in limit_scheme %}{{ scheme }}{% if loop.last == false %}, {% endif %}{% endfor %}'{% endif %}

{% if limit_type or limit_parent or limit_group or limit_scheme %}{% endif %} {% endif %} -{% if global_search and not search_failed and skipped_vocabs|length > 0 %} -
-{% for voc in skipped_vocabs %} -{% set vocTitle = voc.title %} -

{% trans %}Warning: Skipped searching from '{{vocTitle}}' vocabulary!{% endtrans %}

-{% endfor %} -
-{% endif %} {% if search_results is not null and search_results|length == 0 %}

{% trans 'The search provided no results.' %}

{% endif %} {% for concept in search_results %} {# loop through the hits #}