From 5f4fc10df59ea064e2e409a478ca3406a496733d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 2 Jul 2026 13:00:39 -0400 Subject: [PATCH] Bug 42988: Update database, set holds_get_captured default to 1 The migration from SIPconfig.xml to the database ( bug 37893 ) leaves holds_get_captured NULL for any account that didn't define it in the config file. At SIP checkin an unset holds_get_captured defaults to on, but the REST API returns NULL boolean columns as false, so the SIP account editor shows "No" selected. Saving the account without touching the option then stores 0 and holds are no longer captured at SIP checkin. This patch changes the column default to 1 and sets existing NULL values to 1 so the stored value matches the actual checkin behavior. Test Plan: 1) If you have no SIP accounts, create one 2) Simulate an account migrated from a SIPconfig.xml that doesn't define holds_get_captured: UPDATE sip_accounts SET holds_get_captured = NULL; 3) Edit the account, note "Holds get captured" shows "No" even though holds *are* captured at SIP checkin while the value is unset 4) Apply this patch 5) Run updatedatabase.pl 6) SELECT login_id, holds_get_captured FROM sip_accounts; 7) Note holds_get_captured is now 1! 8) Edit the account again, note "Yes" is now selected for "Holds get captured"! Signed-off-by: David Nind Signed-off-by: Emily Lamancusa Signed-off-by: Lucas Gass --- .../data/mysql/atomicupdate/bug_42988.pl | 28 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_42988.pl diff --git a/installer/data/mysql/atomicupdate/bug_42988.pl b/installer/data/mysql/atomicupdate/bug_42988.pl new file mode 100755 index 0000000000..65b6064fc3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_42988.pl @@ -0,0 +1,28 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_success say_failure); + +return { + bug_number => "42988", + description => "Set holds_get_captured default to 1 in sip_accounts", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my $updated = $dbh->do(q{UPDATE sip_accounts SET holds_get_captured = 1 WHERE holds_get_captured IS NULL}); + if ($updated) { + say_success( + $out, + "Set holds_get_captured to 1 for " . ( $updated + 0 ) . " sip_accounts rows where it was NULL" + ); + } else { + say_failure( $out, "Failed to update NULL holds_get_captured rows in sip_accounts: " . $dbh->errstr ); + } + + my $altered = $dbh->do(q{ALTER TABLE sip_accounts ALTER COLUMN holds_get_captured SET DEFAULT 1}); + if ($altered) { + say_success( $out, "Changed default of 'holds_get_captured' in sip_accounts to 1" ); + } else { + say_failure( $out, "Failed to change default of 'holds_get_captured' in sip_accounts: " . $dbh->errstr ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c7b1d13569..5a06277cb4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -6313,7 +6313,7 @@ CREATE TABLE `sip_accounts` ( `format_due_date` tinyint(1) DEFAULT NULL, `hide_fields` varchar(255) DEFAULT NULL, `holds_block_checkin` tinyint(1) DEFAULT NULL, - `holds_get_captured` tinyint(1) DEFAULT NULL, + `holds_get_captured` tinyint(1) DEFAULT 1, `inhouse_item_types` varchar(255) DEFAULT NULL, `inhouse_patron_categories` varchar(255) DEFAULT NULL, `login_id` varchar(255) NOT NULL COMMENT 'Staff userid for SIP2 authentication',