From f14581e235d822cf0496bd3592dd97ab3cda76d8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 25 Jan 2017 09:35:42 -0300 Subject: [PATCH] Bug 17992: REST api: Remove the use of ->unblessed from Cities controller Content-Type: text/plain; charset=utf-8 As bug 17932 adds TO_JSON to Koha::Object(s), there's no need for using it. Also, as this is a reference implementation for developers to copy and paste it is sensible to make this change even when this is not causing any bug. To test: - Apply the patch - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/db_dependent/api/v1/cities.t => SUCCESS: Tests still pass! - Sign off :-D Signed-off-by: Matthias Meusburger Signed-off-by: Marcel de Rooy --- Koha/REST/V1/Cities.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm index e8ababe..5d32ea9 100644 --- a/Koha/REST/V1/Cities.pm +++ b/Koha/REST/V1/Cities.pm @@ -19,7 +19,6 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; -use C4::Auth qw( haspermission ); use Koha::City; use Koha::Cities; @@ -37,7 +36,7 @@ sub list { } return try { - $cities = Koha::Cities->search($filter)->unblessed; + $cities = Koha::Cities->search($filter); return $c->$cb( $cities, 200 ); } catch { @@ -59,7 +58,7 @@ sub get { return $c->$cb( { error => "City not found" }, 404 ); } - return $c->$cb( $city->unblessed, 200 ); + return $c->$cb( $city, 200 ); } sub add { @@ -69,7 +68,7 @@ sub add { return try { $city->store; - return $c->$cb( $city->unblessed, 200 ); + return $c->$cb( $city, 200 ); } catch { if ( $_->isa('DBIx::Class::Exception') ) { @@ -91,7 +90,7 @@ sub update { $city = Koha::Cities->find( $args->{cityid} ); $city->set( $args->{body} ); $city->store(); - return $c->$cb( $city->unblessed, 200 ); + return $c->$cb( $city, 200 ); } catch { if ( not defined $city ) { -- 2.1.4