From 5cce1eba3474f171dced6445bf7ddb68b5982e34 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 23 Apr 2026 07:25:17 -0400 Subject: [PATCH] Bug 42447: SIP template fields in the database are too small The SIP fields in the database are too small for the templates of some configurations, and are truncated during upgrade resulting in invalid templates. It's likely we need more than 255 characters for some templates. We should convert all sip template fields to TEXT fields. Test Plan: 1) For each template field on a sip account attempt to save a template like: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXY 2) Note error preventing you from doing so 3) Apply this patch 4) Run updatedatabase.pl 5) Repeat step 1 6) Note you can now do so without error! Signed-off-by: Charlie Arthur Signed-off-by: Pedro Amorim Signed-off-by: Lucas Gass (cherry picked from commit 7693360a0fc0eaca96b1f66a955459255151cf6f) Signed-off-by: Jacob O'Mara --- .../data/mysql/atomicupdate/bug_42447.pl | 37 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 10 ++--- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_42447.pl diff --git a/installer/data/mysql/atomicupdate/bug_42447.pl b/installer/data/mysql/atomicupdate/bug_42447.pl new file mode 100755 index 0000000000..f5b4d43042 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_42447.pl @@ -0,0 +1,37 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "42447", + description => "Convert SIP template fields to TEXT", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + ALTER TABLE `sip_accounts` + MODIFY COLUMN `ae_field_template` TEXT DEFAULT NULL, + MODIFY COLUMN `av_field_template` TEXT DEFAULT NULL, + MODIFY COLUMN `da_field_template` TEXT DEFAULT NULL + } + ); + say_success( $out, "Converted sip_accounts template columns to TEXT" ); + + $dbh->do( + q{ + ALTER TABLE `sip_account_custom_item_fields` + MODIFY COLUMN `template` TEXT NOT NULL COMMENT 'Template toolkit template' + } + ); + say_success( $out, "Converted sip_account_custom_item_fields.template to TEXT" ); + + $dbh->do( + q{ + ALTER TABLE `sip_account_custom_patron_fields` + MODIFY COLUMN `template` TEXT NOT NULL COMMENT 'Template toolkit template' + } + ); + say_success( $out, "Converted sip_account_custom_patron_fields.template to TEXT" ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b338a34ff0..5860dfcf0a 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -6061,7 +6061,7 @@ CREATE TABLE `sip_account_custom_item_fields` ( `sip_account_custom_item_field_id` int(11) NOT NULL AUTO_INCREMENT, `sip_account_id` int(11) NOT NULL COMMENT 'Foreign key to sip_accounts.sip_account_id', `field` varchar(80) NOT NULL COMMENT 'SIP field name e.g. XY', - `template` varchar(255) NOT NULL COMMENT 'Template toolkit template name', + `template` text NOT NULL COMMENT 'Template toolkit template', PRIMARY KEY (`sip_account_custom_item_field_id`), UNIQUE KEY `sip_account` (`sip_account_custom_item_field_id`,`sip_account_id`), KEY `sip_account_custom_item_fields_ibfk_1` (`sip_account_id`), @@ -6080,7 +6080,7 @@ CREATE TABLE `sip_account_custom_patron_fields` ( `sip_account_custom_patron_field_id` int(11) NOT NULL AUTO_INCREMENT, `sip_account_id` int(11) NOT NULL COMMENT 'Foreign key to sip_accounts.sip_account_id', `field` varchar(80) NOT NULL COMMENT 'SIP field name e.g. XY', - `template` varchar(80) NOT NULL COMMENT 'Template toolkit template', + `template` text NOT NULL COMMENT 'Template toolkit template', PRIMARY KEY (`sip_account_custom_patron_field_id`), UNIQUE KEY `sip_account` (`sip_account_custom_patron_field_id`,`sip_account_id`), KEY `sip_account_custom_patron_fields_ibfk_1` (`sip_account_id`), @@ -6192,11 +6192,11 @@ DROP TABLE IF EXISTS `sip_accounts`; CREATE TABLE `sip_accounts` ( `sip_account_id` int(11) NOT NULL AUTO_INCREMENT, `sip_institution_id` int(11) NOT NULL COMMENT 'Foreign key to sip_institutions.sip_institution_id', - `ae_field_template` varchar(255) DEFAULT NULL, + `ae_field_template` text DEFAULT NULL, `allow_additional_materials_checkout` tinyint(1) DEFAULT NULL, `allow_empty_passwords` tinyint(1) DEFAULT NULL, `allow_fields` varchar(255) DEFAULT NULL, - `av_field_template` varchar(255) DEFAULT NULL, + `av_field_template` text DEFAULT NULL, `blocked_item_types` varchar(255) DEFAULT NULL, `checked_in_ok` tinyint(1) DEFAULT NULL, `convert_nonprinting_characters` varchar(10) DEFAULT NULL, @@ -6204,7 +6204,7 @@ CREATE TABLE `sip_accounts` ( `ct_always_send` tinyint(1) DEFAULT NULL, `cv_send_00_on_success` tinyint(1) DEFAULT NULL, `cv_triggers_alert` tinyint(1) DEFAULT NULL, - `da_field_template` varchar(255) DEFAULT NULL, + `da_field_template` text DEFAULT NULL, `delimiter` varchar(10) DEFAULT '|', `disallow_overpayment` tinyint(1) DEFAULT NULL, `encoding` varchar(10) DEFAULT NULL,