Bugzilla – Attachment 26645 Details for
Bug 8868
ILS-DI: CancelHold needs to take a reserve_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8868: Remove CancelReserveFromId
Bug-8868-Remove-CancelReserveFromId.patch (text/plain), 5.22 KB, created by
Benjamin Rokseth
on 2014-03-27 13:37:41 UTC
(
hide
)
Description:
Bug 8868: Remove CancelReserveFromId
Filename:
MIME Type:
Creator:
Benjamin Rokseth
Created:
2014-03-27 13:37:41 UTC
Size:
5.22 KB
patch
obsolete
>From 9f7e2ed87ba5c69281981c0aafcb484090248d5a Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 14 Mar 2014 10:52:03 +0100 >Subject: [PATCH] Bug 8868: Remove CancelReserveFromId > >CancelReserve does the same job. > >Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> >--- > C4/ILSDI/Services.pm | 2 +- > C4/Reserves.pm | 89 ++++++++--------------------------------------- > t/db_dependent/Reserves.t | 9 ++--- > 3 files changed, 20 insertions(+), 80 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 0df6680..773a64d 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -742,7 +742,7 @@ sub CancelHold { > return { code => 'RecordNotFound' } unless $reserve; > return { code => 'RecordNotFound' } unless ($reserve->{borrowernumber} == $borrowernumber); > >- C4::Reserves::CancelReserveFromId($reserve_id); >+ C4::Reserves::CancelReserve({reserve_id => $reserve_id}); > > return { code => 'Canceled' }; > } >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index e649296..670908e 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -117,9 +117,8 @@ BEGIN { > > &CheckReserves > &CanBookBeReserved >- &CanItemBeReserved >+ &CanItemBeReserved > &CancelReserve >- &CancelReserveFromId > &CancelExpiredReserves > > &AutoUnsuspendReserves >@@ -1031,86 +1030,26 @@ sub CancelReserve { > return unless ( $reserve_id ); > > my $dbh = C4::Context->dbh; >- > my $reserve = GetReserve( $reserve_id ); >- >- my $query = " >- UPDATE reserves >- SET cancellationdate = now(), >- found = Null, >- priority = 0 >- WHERE reserve_id = ? >- "; >- my $sth = $dbh->prepare($query); >- $sth->execute( $reserve_id ); >- >- $query = " >- INSERT INTO old_reserves >- SELECT * FROM reserves >- WHERE reserve_id = ? >- "; >- $sth = $dbh->prepare($query); >- $sth->execute( $reserve_id ); >- >- $query = " >- DELETE FROM reserves >- WHERE reserve_id = ? >- "; >- $sth = $dbh->prepare($query); >- $sth->execute( $reserve_id ); >- >- # now fix the priority on the others.... >- _FixPriority({ biblionumber => $reserve->{biblionumber} }); >-} >- >-=head2 CancelReserveFromId >- >- C4::Reserves::CancelReserveFromId($reserve_id); >- >-Cancel a reserve, given its reserve_id >- >-=cut >- >-sub CancelReserveFromId { >- my ($reserve_id) = @_; >- >- my $reserve = GetReserve($reserve_id); > if ($reserve) { >- my $dbh = C4::Context->dbh; >- >- # update the database, removing the record... >- my $query = qq{ >+ my $query = " > UPDATE reserves >- SET cancellationdate = NOW(), >- found = NULL, >- priority = 0 >- WHERE reserve_id = ? >- }; >+ SET cancellationdate = now(), >+ found = Null, >+ priority = 0 >+ WHERE reserve_id = ? >+ "; > my $sth = $dbh->prepare($query); >- $sth->execute($reserve_id); >- $sth->finish; >+ $sth->execute( $reserve_id ); > >- $query = qq{ >- INSERT INTO old_reserves >- SELECT * FROM reserves >- WHERE reserve_id = ? >- }; >+ $query = " >+ DELETE FROM reserves >+ WHERE reserve_id = ? >+ "; > $sth = $dbh->prepare($query); >- my $rv = $sth->execute($reserve_id); >- >- if ($rv) { >- $query = qq{ >- DELETE FROM reserves >- WHERE reserve_id = ? >- }; >- $sth = $dbh->prepare($query); >- $sth->execute($reserve_id); >- } else { >- warn "ERROR: Failed to move reserve $reserve_id to table old_reserves."; >- return; >- } >+ $sth->execute( $reserve_id ); > >- # now fix the priority on the others... >+ # now fix the priority on the others.... > _FixPriority({ biblionumber => $reserve->{biblionumber} }); > } > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 8401c21..a4fd43a 100644 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -238,15 +238,16 @@ $reserve = GetReserve($reserve_id); > isa_ok($reserve, 'HASH', "GetReserve return"); > is($reserve->{biblionumber}, $biblionumber); > >-$reserve = CancelReserveFromId($reserve_id); >-isa_ok($reserve, 'HASH', "CancelReserveFromId return"); >+$reserve = CancelReserve({reserve_id => $reserve_id}); >+isa_ok($reserve, 'HASH', "CancelReserve return"); > is($reserve->{biblionumber}, $biblionumber); > > $reserve = GetReserve($reserve_id); > is($reserve, undef, "GetReserve returns undef after deletion"); > >-$reserve = CancelReserveFromId($reserve_id); >-is($reserve, undef, "CancelReserveFromId return undef if reserve does not exist"); >+$reserve = CancelReserve({reserve_id => $reserve_id}); >+is($reserve, undef, "CancelReserve return undef if reserve does not exist"); >+ > > # Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn > # Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8868
:
12657
|
16313
|
16527
|
18921
|
21337
|
21338
|
22723
|
22724
|
24879
|
26150
|
26271
|
26333
|
26645
|
27023
|
27024
|
27771
|
27947
|
30881
|
30908
|
30909