From 13c1588cd69f8e6e445c176906759637251ffb55 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 Apr 2025 11:06:19 +0200 Subject: [PATCH] Bug 38010: Fix wrong use of scalar in the REST API controller It was wrong, we need to use scalar on the array, not the arrayref (otherwise it will always be true) No change in behaviour expected here, just some code cleaning (cherry picked from commit 7abbcb7ba73da13d988202aaf06ba239e21692da) Signed-off-by: Jonathan Druart --- Koha/REST/V1/Acquisitions/Vendors.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Vendors.pm b/Koha/REST/V1/Acquisitions/Vendors.pm index 8b61de68797..9cd94eb26ac 100644 --- a/Koha/REST/V1/Acquisitions/Vendors.pm +++ b/Koha/REST/V1/Acquisitions/Vendors.pm @@ -95,9 +95,9 @@ sub add { return try { $vendor_to_store->store; - $vendor_to_store->contacts($contacts) if scalar($contacts) > 0; - $vendor_to_store->aliases($aliases) if scalar($aliases) > 0; - $vendor_to_store->interfaces($interfaces) if scalar($interfaces) > 0; + $vendor_to_store->contacts( $contacts || [] ); + $vendor_to_store->aliases( $aliases || [] ); + $vendor_to_store->interfaces( $interfaces || [] ); $c->res->headers->location( $c->req->url->to_string . '/' . $vendor_to_store->id ); return $c->render( @@ -133,9 +133,9 @@ sub update { $vendor->set_from_api($vendor_update); $vendor->store(); - $vendor->contacts($contacts) if scalar($contacts) > 0; - $vendor->aliases($aliases) if scalar($aliases) > 0; - $vendor->interfaces($interfaces) if scalar($interfaces) > 0; + $vendor->contacts( $contacts || [] ); + $vendor->aliases( $aliases || [] ); + $vendor->interfaces( $interfaces || [] ); return $c->render( status => 200, -- 2.34.1