Bug 28754: Only adjust holds on specific biblio and don't go past end of array
authorNick Clemens <nick@bywatersolutions.com>
Fri, 23 Jul 2021 17:56:39 +0000 (17:56 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 6 Aug 2021 18:07:59 +0000 (14:07 -0400)
commita1748ae566cda791d3b9a9878574601c34f8bf73
tree5e44a687e4651d1b1e7d151b96cd8577f7e04de1
parent58651f2219ced5656573a2c11fa31f6a266c3782
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>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Reserves.pm