Bugzilla – Attachment 123158 Details for
Bug 28754
C4::Reserves::FixPriority creates many warns when holds have lowestPriority set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28754: Only adjust holds on specific biblio and don't go past end of array
Bug-28754-Only-adjust-holds-on-specific-biblio-and.patch (text/plain), 2.44 KB, created by
David Nind
on 2021-07-24 20:51:06 UTC
(
hide
)
Description:
Bug 28754: Only adjust holds on specific biblio and don't go past end of array
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-07-24 20:51:06 UTC
Size:
2.44 KB
patch
obsolete
>From cab04bab01735f86906438f70dccf889587f2319 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 23 Jul 2021 17:56:39 +0000 >Subject: [PATCH] Bug 28754: Only adjust holds on specific biblio and don't go > past end of array > >Our query for lowest priority holds only needs to adjust holds on the biblio we are looking at >so I add biblionumber > >Additionally we can simply find the end of the array and use that rather than 99998 >so I set new_rank to scalar @priority > >Lastly, we don't need to fetch the lowest priority holds if we are ignoring lowest priority >so I move it into the conditional > >To test: > 1 - Add holds with lowest priorty to 2 records in the catalog > 2 - Add a hold on a third record > 3 - Note errors in log like: > [2021/07/23 17:47:17] [WARN] splice() offset past end of array at /kohadevbox/koha/C4/Reserves.pm line 1649 > 4 - Apply patch and restart all the things > 5 - Add a new hold on third record - no warns > 6 - Make one of the holds on third record have lowestPriority (click rightmost arrow with line at bottom) > 7 - Note no warns > 8 - Adjust other holds on record and note no warns > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Reserves.pm | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 54d2b00cb0..1d5ec22db2 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1643,9 +1643,9 @@ sub _FixPriority { > > # if index exists in array then move it to new position > if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { >- my $new_rank = $rank - >- 1; # $new_rank is what you want the new index to be in the array >+ my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array > my $moving_item = splice( @priority, $key, 1 ); >+ $new_rank = scalar @priority if $new_rank > scalar @priority; > splice( @priority, $new_rank, 0, $moving_item ); > } > >@@ -1663,10 +1663,9 @@ sub _FixPriority { > ); > } > >- $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); >- $sth->execute(); >- > unless ( $ignoreSetLowestRank ) { >+ $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 AND biblionumber = ? ORDER BY priority" ); >+ $sth->execute($biblionumber); > while ( my $res = $sth->fetchrow_hashref() ) { > _FixPriority({ > reserve_id => $res->{'reserve_id'}, >-- >2.20.1
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 28754
:
123147
|
123158
|
123242