From a0982a46225b16283e3236d7fdf925abccb103bf Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 4 Mar 2022 16:19:35 +0000 Subject: [PATCH] Bug 24001: Fix Card template/rpinter profile creation and edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adjusts the template/profiles to use the default of '0' This should probably be NULL, and the columns foreign keys, this code could use a further rewrite, but this should fix a long standing bug To test: 1 - Using the fresh install, with all the sample data. 2 - Go to Home › Tools › Patron card creator › Templates 3 - New > Card template 4 - Save 5 - Error: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'profile_id' at row 1 6 - Edit an existing template 7 - Save 8 - Error: Can't bless non-reference value at /kohadevbox/koha/C4/Creators/Profile.pm line 89 9 - Create a new 'Printer profile' 10 - Save 11 - Error: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'template_id' at row 1 12 - Apply the attached patch. 13 - Verify you can create a new 'Card template' and 'Printer profile' with no errors 14 - Verify you can edit and save both of the newly created objects above --- C4/Creators/Profile.pm | 2 +- patroncards/edit-template.pl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Creators/Profile.pm b/C4/Creators/Profile.pm index cd1de4038b..b9759bd6a8 100644 --- a/C4/Creators/Profile.pm +++ b/C4/Creators/Profile.pm @@ -59,7 +59,7 @@ sub new { my $type = ref($invocant) || $invocant; my $self = { printer_name => 'Default Printer', - template_id => '', + template_id => 0, paper_bin => 'Tray 1', offset_horz => 0, offset_vert => 0, diff --git a/patroncards/edit-template.pl b/patroncards/edit-template.pl index 0238701162..62f8cdf014 100755 --- a/patroncards/edit-template.pl +++ b/patroncards/edit-template.pl @@ -47,10 +47,10 @@ my $units = get_unit_values(); if ($op eq 'edit') { $card_template = C4::Patroncards::Template->retrieve(template_id => $template_id); - $profile_list = get_all_profiles({ fields => [ qw( profile_id printer_name paper_bin ) ], filters => {template_id => [ $template_id, '' ]} } ); + $profile_list = get_all_profiles({ fields => [ qw( profile_id printer_name paper_bin ) ], filters => {template_id => [ $template_id, '' ], creator => 'Patroncards'} } ); } elsif ($op eq 'save') { - my @params = ( profile_id => scalar $cgi->param('profile_id') || '', + my @params = ( profile_id => scalar $cgi->param('profile_id') || 0, template_code => scalar $cgi->param('template_code'), template_desc => scalar $cgi->param('template_desc'), page_width => scalar $cgi->param('page_width'), -- 2.30.2