Bugzilla – Attachment 90400 Details for
Bug 23070
Use Koha::Hold in C4::Reserves::RevertWaitingStatus
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23070: Use Koha::Hold in C4::Reserves::RevertWaitingStatus
Bug-23070-Use-KohaHold-in-C4ReservesRevertWaitingS.patch (text/plain), 2.49 KB, created by
Jonathan Druart
on 2019-06-06 20:15:58 UTC
(
hide
)
Description:
Bug 23070: Use Koha::Hold in C4::Reserves::RevertWaitingStatus
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-06-06 20:15:58 UTC
Size:
2.49 KB
patch
obsolete
>From 5e82bab5f40487251f7e49122f272b99acb89808 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Jun 2019 15:14:28 -0500 >Subject: [PATCH] Bug 23070: Use Koha::Hold in > C4::Reserves::RevertWaitingStatus > >We are using raw SQL statements, we should use Koha::Hold instead. > >This patch does not seem optimal, we would like to increment priority in >only 1 statement and without the need to fetch and loop all holds. >--- > C4/Reserves.pm | 45 ++++++++++++--------------------------------- > 1 file changed, 12 insertions(+), 33 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 097a5c09d6..b1960a97fe 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1886,49 +1886,28 @@ sub RevertWaitingStatus { > my $dbh = C4::Context->dbh; > > ## Get the waiting reserve we want to revert >- my $query = " >- SELECT * FROM reserves >- WHERE itemnumber = ? >- AND found IS NOT NULL >- "; >- my $sth = $dbh->prepare( $query ); >- $sth->execute( $itemnumber ); >- my $reserve = $sth->fetchrow_hashref(); >- >- my $hold = Koha::Holds->find( $reserve->{reserve_id} ); # TODO Remove the next raw SQL statements and use this instead >+ my $hold = Koha::Holds->search( >+ { >+ itemnumber => $itemnumber, >+ found => { not => undef }, >+ } >+ )->next; > > ## Increment the priority of all other non-waiting > ## reserves for this bib record >- $query = " >- UPDATE reserves >- SET >- priority = priority + 1 >- WHERE >- biblionumber = ? >- AND >- priority > 0 >- "; >- $sth = $dbh->prepare( $query ); >- $sth->execute( $reserve->{'biblionumber'} ); >+ my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } }); >+ while ( my $h = $holds->next ) { >+ $h->priority( $h->priority + 1 )->store; >+ } > > ## Fix up the currently waiting reserve >- $query = " >- UPDATE reserves >- SET >- priority = 1, >- found = NULL, >- waitingdate = NULL >- WHERE >- reserve_id = ? >- "; >- $sth = $dbh->prepare( $query ); >- $sth->execute( $reserve->{'reserve_id'} ); >+ $hold->set( { priority => 1, found => undef, waitingdate => undef } )->store; > > unless ( $hold->item_level_hold ) { > $hold->itemnumber(undef)->store; > } > >- _FixPriority( { biblionumber => $reserve->{biblionumber} } ); >+ _FixPriority( { biblionumber => $hold->biblionumber } ); > } > > =head2 ReserveSlip >-- >2.11.0
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 23070
:
90400
|
97976
|
97977
|
99168
|
99169
|
99170
|
103907
|
103908
|
103909
|
103910
|
104253
|
104261
|
104262
|
104263
|
104264
|
106556
|
106557
|
106558
|
106559