Currently, C4::Reserves->FixPriority adjusts the holds not marked for lowestPriority, then recursively calls itself for each lowestPriority hold, touching all the non-found holds on the record each time. This can be removed as we can simply sort the lowestPriority holds to the bottom when getting the list of holds to adjust
Created attachment 192820 [details] [review] Bug 41801: Remove recursive calls from FixPriority This patch removes the recursive calls that set each 'lowestPriority' hold to the bottom of the priority list and replaces it them by simply ordering the list of 'remaining' holds by lowestPriorty, then priority. A check is also added to ensure that if a lowestPriority hold is being adjusted, it cannot be moved above holds not marked as lowest priority. To test: 1 - Place many holds on a record, 50 - 150 https://github.com/kidclamp/handy-koha-script/blob/main/randhold.pl This will randomly make some of the holds lowest priority 2 - View the record in the staff interface: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=312 3 - Click on the 'Holds' tab 4 - Adjust the priority of several holds using the dropdowns 5 - Note the timing 6 - Apply the patch 7 - Adjust the priority of several holds using the dropdowns 8 - Confirm the timing is improved 9 - Confirm that holds adjust as expected 10 - Confirm you cannot move a lowest priority hold above a hold not marked lowest priority 11 - Confirm holds move correctly on a record where all holds are lowestPriority 12 - Confirm holds move correctly on a record where no holds are lowestPriority