From e9344a5ddb79c6370661cf39a23b4e59b55351a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Thu, 10 Oct 2024 19:04:36 +0100 Subject: [PATCH 1/3] fix: Aspen Error messages are shown When an Aspen error is thrown for EBSCO EDS search and the searchError.tpl file is displayed, instead of the original error message, this php error is shown: Cannot use object of type AspenError as array Test plan: - navigate to Aspen Administration > EBSCO EDS > Settings - create a new Setting, make sure to use invalid credentials and save - navigate to Aspen Administration > Primary Configuration > Library Systems and select your current Library - set its EDS Setting to the setting you just created - run a search in Articles and Databases Before this commit: The error message is uninformative (Cannot use object of type AspenError as array). After this commit: The error message refers to a specific cause. --- .../interface/themes/responsive/EBSCO/searchError.tpl | 4 ++-- code/web/sys/SearchObject/EbscoEdsSearcher.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/web/interface/themes/responsive/EBSCO/searchError.tpl b/code/web/interface/themes/responsive/EBSCO/searchError.tpl index 4436c7d748..32bb9a5c52 100644 --- a/code/web/interface/themes/responsive/EBSCO/searchError.tpl +++ b/code/web/interface/themes/responsive/EBSCO/searchError.tpl @@ -10,10 +10,10 @@ {/if} - {if !empty($searchError) && !empty($searchError.error.msg)} + {if !empty($searchError) && !empty($searchError->getMessage())}

{translate text="Error description" isPublicFacing=true}

- {$searchError.error.msg} + {$searchError->getMessage()}
{/if} \ No newline at end of file diff --git a/code/web/sys/SearchObject/EbscoEdsSearcher.php b/code/web/sys/SearchObject/EbscoEdsSearcher.php index b5046d590e..89feafe158 100644 --- a/code/web/sys/SearchObject/EbscoEdsSearcher.php +++ b/code/web/sys/SearchObject/EbscoEdsSearcher.php @@ -186,12 +186,12 @@ public function authenticate() { return true; } elseif ($createSessionResponse->ErrorDescription) { echo("create session failed, " . print_r($createSessionResponse)); - return false; + return new AspenError("Error processing search in EBSCO EDS"); } } } else { echo("Authentication failed!, $return"); - return false; + return new AspenError("Error processing search in EBSCO EDS: Authentication failed"); } } else { return false; @@ -553,9 +553,13 @@ function getSearchesFile() { } public function processSearch($returnIndexErrors = false, $recommendations = false, $preventQueryModification = false) { - if (!$this->authenticate()) { + $isAuthenticated = $this->authenticate(); + if (empty($isAuthenticated)) { return null; } + if (get_class($isAuthenticated) == 'AspenError') { + return $isAuthenticated; + } $this->startQueryTimer(); $hasSearchTerm = false; From 7ee7e2a309b34ab9b12ddccffba0ac78593559dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Thu, 10 Oct 2024 19:45:05 +0100 Subject: [PATCH 2/3] fix: errors are logged not echoed Test plan: - navigate to Aspen Administration > EBSCO EDS > Settings - create a new Setting, make sure to use invalid credentials and save - navigate to Aspen Administration > Primary Configuration > Library Systems and select your current Library - set its EDS Setting to the setting you just created - log out - run a search in Articles and Databases Before this commit: An error message appears at the top of the screen. This message contains the information sent back by EDS. After this commit: The error message does not show on screen anymore and is logged instead. --- code/web/sys/SearchObject/EbscoEdsSearcher.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/web/sys/SearchObject/EbscoEdsSearcher.php b/code/web/sys/SearchObject/EbscoEdsSearcher.php index 89feafe158..4f8c3e8283 100644 --- a/code/web/sys/SearchObject/EbscoEdsSearcher.php +++ b/code/web/sys/SearchObject/EbscoEdsSearcher.php @@ -126,6 +126,7 @@ public function getCurlConnection() { } public function authenticate() { + global $logger; if (SearchObject_EbscoEdsSearcher::$authenticationToken == null) { global $library; $settings = $this->getSettings(); @@ -185,12 +186,12 @@ public function authenticate() { //echo("Authenticated in EDS!"); return true; } elseif ($createSessionResponse->ErrorDescription) { - echo("create session failed, " . print_r($createSessionResponse)); + $logger->log("create session failed, " . print_r($createSessionResponse, true), Logger::LOG_WARNING); return new AspenError("Error processing search in EBSCO EDS"); } } } else { - echo("Authentication failed!, $return"); + $logger->log("Error processing search in EBSCO EDS: " . print_r($return, true), Logger::LOG_WARNING); return new AspenError("Error processing search in EBSCO EDS: Authentication failed"); } } else { From db9aed09e7fdc5cac8167e7fd0f01fcedeb5ddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Fri, 11 Oct 2024 10:54:40 +0100 Subject: [PATCH 3/3] docs: update release notes --- code/web/release_notes/24.10.00.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/release_notes/24.10.00.MD b/code/web/release_notes/24.10.00.MD index f068d4d798..94e2d8ed21 100644 --- a/code/web/release_notes/24.10.00.MD +++ b/code/web/release_notes/24.10.00.MD @@ -173,6 +173,7 @@ - E-commerce: SnapPay: drop unused database field and other small fixes. (*JStaub*) - Correct cron artifact within new default intellij project. (*MDN*) - When batch updating enumerations, display the label for the new value rather than the internal value. (*MDN*) +- Fix an issue where EBSCO EDS search errors were echoed to the UI on the search page (visible to any visitor) by adding the error message to the logs instead. (*CZ*) ## This release includes code contributions from ###ByWater Solutions