From df58ae1ae0a69d899cb1c970b85789632a3ab8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Tue, 3 Dec 2024 18:31:05 +0000 Subject: [PATCH] fix: do not proceed if no setting found Removes an unecessary fetch() call as find(true) already executes a fetch(), and changes the control flow so that getLibKeyLink() returns null early if no setting is found (only move on to creating an instance of CurlWrapper if the setting was found). --- code/web/Drivers/LibKeyDriver.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/web/Drivers/LibKeyDriver.php b/code/web/Drivers/LibKeyDriver.php index aa70bf4279..16d2439aee 100644 --- a/code/web/Drivers/LibKeyDriver.php +++ b/code/web/Drivers/LibKeyDriver.php @@ -1,14 +1,13 @@ whereAdd("id=$activeLibrary->libKeySettingId"); - if ($settings->find(true)) { - $settings->fetch(); + if (!$settings->find(true)) { + return null; } $curlWrapper = new CurlWrapper; $response = $curlWrapper->curlGetPage("https://public-api.thirdiron.com/public/v1/libraries/" . $settings->libraryId . "/articles/doi/" . $this->extractDoi($doiUrl) . "?access_token=" . $settings->apiKey);