From 4da89716d1389b68be28840ccd85d97ee18913aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Tue, 22 Oct 2019 12:39:35 +0000 Subject: [PATCH] Bug 18795: (follow-up) Check whether patrons exists before deleting history Running $patrons->anonymise_issue_history after checking patrons exists is more logical even though $patrons->anonymise_issue_history() can handle 0 patrons returned in the search. Also this way we don't have to run anonymise_issue_history() code unless needed, thus making the code finish faster. Signed-off-by: Bouzid Fergani --- Koha/REST/V1/Checkouts.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm index 26d1da0..17614a6 100644 --- a/Koha/REST/V1/Checkouts.pm +++ b/Koha/REST/V1/Checkouts.pm @@ -197,14 +197,14 @@ sub delete_history { 'me.borrowernumber' => $patron_id }); - $patrons->anonymise_issue_history; - unless ($patrons->count) { return $c->render( status => 404, openapi => { error => "Patron doesn't exist" }); } + $patrons->anonymise_issue_history; + return $c->render( status => 204, openapi => "" ); } -- 2.7.4