Bugzilla – Attachment 191979 Details for
Bug 41698
Add maintenance script to revert found holds for items currently checked out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41698 - Add maintenance script to revert found holds for items currently checked out
7ffba28.patch (text/plain), 3.53 KB, created by
Kyle M Hall (khall)
on 2026-01-23 19:15:35 UTC
(
hide
)
Description:
Bug 41698 - Add maintenance script to revert found holds for items currently checked out
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2026-01-23 19:15:35 UTC
Size:
3.53 KB
patch
obsolete
>From 7ffba280c786ccd2b3b57d392b00e08462561b0a Mon Sep 17 00:00:00 2001 >From: John Doe <you@example.com> >Date: Fri, 23 Jan 2026 19:08:26 +0000 >Subject: [PATCH] Bug 41698 - Add maintenance script to revert found holds for > items currently checked out > >For reasons unknown, it is possible to get into a situation where an item is both checked out to one patron and associated with a found hold for another patron. We should add a script to Koha to fix items in this situation by reverting the found holds. > >Test Plan: >1) Check an item out to a patron >2) Place an item specific hold for another patron >3) Manually set the priority to 0 and found to "W" for that hold >4) Run misc/maintenance/fix_holds_waiting_and_issued.pl >5) Note the hold has been reverted! >--- > .../fix_holds_waiting_and_issued.pl | 97 +++++++++++++++++++ > 1 file changed, 97 insertions(+) > create mode 100755 misc/maintenance/fix_holds_waiting_and_issued.pl > >diff --git a/misc/maintenance/fix_holds_waiting_and_issued.pl b/misc/maintenance/fix_holds_waiting_and_issued.pl >new file mode 100755 >index 00000000000..8b29e0a1375 >--- /dev/null >+++ b/misc/maintenance/fix_holds_waiting_and_issued.pl >@@ -0,0 +1,97 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Script; >+use Koha::Holds; >+ >+use C4::Context; >+ >+use Getopt::Long qw( GetOptions ); >+ >+=head1 NAME >+ >+fix_holds_waiting_and_issued.pl - Revert waiting holds on items that are currently checked out >+ >+=head1 SYNOPSIS >+ >+fix_holds_waiting_and_issued.pl >+ >+=head1 DESCRIPTION >+ >+Sometimes it is possible to end up with items that are both checked out to a patron, and associated >+with a hold waiting to be picked up by a different patron. This script finds those items and reverts >+the waiting holds. >+ >+=over 8 >+ >+=item B<--help> >+ >+Prints a brief usage message and exits. >+ >+=item B<-c> >+ >+Confirms this script should alter the found holds. >+ >+=back >+ >+=cut >+ >+my $help = 0; >+my $confirm; >+ >+sub print_usage { >+ print <<_USAGE_; >+$0: Revert waiting holds on items that are currently checked out >+ >+Sometimes it is possible to end up with items that are both checked out to a patron, and associated >+with a hold waiting to be picked up by a different patron. This script finds those items and reverts >+the waiting holds. >+ >+Parameters: >+ -c, --confirm Confirm the script should make the changes >+ -h, --help Print out this help message. >+_USAGE_ >+} >+ >+my $result = GetOptions( >+ 'help|h' => \$help, >+ 'confirm|c' => \$confirm, >+); >+ >+if ( $help || !$confirm ) { >+ print_usage(); >+ exit 0; >+} >+ >+my $dbh = C4::Context->dbh; >+my $sth = $dbh->prepare( >+ q{ >+ SELECT reserve_id FROM issues >+ LEFT JOIN reserves USING ( itemnumber ) >+ WHERE found IS NOT NULL >+} >+); >+$sth->execute(); >+ >+while ( my $r = $sth->fetchrow_hashref ) { >+ my $reserve_id = $r->{reserve_id}; >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ $hold->revert_found(); >+} >-- >2.50.1 (Apple Git-155) >
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 41698
:
191978
| 191979 |
191980