Bug 23070: Increment all priorities in 1 query
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 27 Jan 2020 13:55:54 +0000 (14:55 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Jul 2020 14:16:37 +0000 (16:16 +0200)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Reserves.pm

index a78f2a4..2a5904f 100644 (file)
@@ -2006,10 +2006,8 @@ sub RevertWaitingStatus {
 
     ## Increment the priority of all other non-waiting
     ## reserves for this bib record
-    my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } });
-    while ( my $h = $holds->next ) {
-        $h->priority( $h->priority + 1 )->store;
-    }
+    my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } })
+                           ->update({ priority => \'priority + 1' });
 
     ## Fix up the currently waiting reserve
     $hold->set(