From b8d5a69e4e145f6684507b62267759f1ea465e80 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 23 Sep 2010 13:52:40 -0400 Subject: [PATCH] Bug 5203 - Creating a label template causes fatal error if description field is empty This is due to the underlying script not having any defaults hard coded which results in skewed hash elements when the parameter array is coerced into a hash at a later point. This also occurs in layouts and profiles. This patch adds defaults to all three. No documentation changes are necessary. --- labels/label-edit-layout.pl | 14 +++++++------- labels/label-edit-profile.pl | 14 +++++++------- labels/label-edit-template.pl | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index a1879af190..470092d90e 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -122,15 +122,15 @@ elsif ($op eq 'save') { $cgi->param('format_string', $format_string); } my @params = ( - barcode_type => $cgi->param('barcode_type'), - printing_type => $cgi->param('printing_type'), - layout_name => $cgi->param('layout_name'), + barcode_type => $cgi->param('barcode_type') || 'CODE39', + printing_type => $cgi->param('printing_type') || 'BAR', + layout_name => $cgi->param('layout_name') || 'DEFAULT', guidebox => ($cgi->param('guidebox') ? 1 : 0), - font => $cgi->param('font'), - font_size => $cgi->param('font_size'), + font => $cgi->param('font') || 'TR', + font_size => $cgi->param('font_size') || 3, callnum_split => ($cgi->param('callnum_split') ? 1 : 0), - text_justify => $cgi->param('text_justify'), - format_string => $cgi->param('format_string'), + text_justify => $cgi->param('text_justify') || 'L', + format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, callnumber', ); if ($layout_id) { # if a label_id was passed in, this is an update to an existing layout $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id); diff --git a/labels/label-edit-profile.pl b/labels/label-edit-profile.pl index baaeb8ad76..b1145548f2 100755 --- a/labels/label-edit-profile.pl +++ b/labels/label-edit-profile.pl @@ -54,13 +54,13 @@ if ($op eq 'edit') { } elsif ($op eq 'save') { my @params = ( - printer_name => $cgi->param('printer_name'), - paper_bin => $cgi->param('paper_bin'), - offset_horz => $cgi->param('offset_horz'), - offset_vert => $cgi->param('offset_vert'), - creep_horz => $cgi->param('creep_horz'), - creep_vert => $cgi->param('creep_vert'), - units => $cgi->param('units'), + printer_name => $cgi->param('printer_name') || 'DEFAULT PRINTER', + paper_bin => $cgi->param('paper_bin') || 'Tray 1', + offset_horz => $cgi->param('offset_horz') || 0, + offset_vert => $cgi->param('offset_vert') || 0, + creep_horz => $cgi->param('creep_horz') || 0, + creep_vert => $cgi->param('creep_vert') || 0, + units => $cgi->param('units') || 'POINT', ); if ($profile_id) { # if a label_id was passed in, this is an update to an existing layout $profile = C4::Labels::Profile->retrieve(profile_id => $profile_id); diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl index a645feec81..f0a6ab0773 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -53,21 +53,21 @@ if ($op eq 'edit') { } elsif ($op eq 'save') { my @params = ( profile_id => $cgi->param('profile_id') || '', - template_code => $cgi->param('template_code'), - template_desc => $cgi->param('template_desc'), - page_width => $cgi->param('page_width'), - page_height => $cgi->param('page_height'), - label_width => $cgi->param('label_width'), - label_height => $cgi->param('label_height'), - top_text_margin => $cgi->param('top_text_margin'), - left_text_margin=> $cgi->param('left_text_margin'), - top_margin => $cgi->param('top_margin'), - left_margin => $cgi->param('left_margin'), - cols => $cgi->param('cols'), - rows => $cgi->param('rows'), - col_gap => $cgi->param('col_gap'), - row_gap => $cgi->param('row_gap'), - units => $cgi->param('units'), + template_code => $cgi->param('template_code') || 'DEFAULT_TEMPLATE', + template_desc => $cgi->param('template_desc') || 'Default description', + page_width => $cgi->param('page_width') || 0, + page_height => $cgi->param('page_height') || 0, + label_width => $cgi->param('label_width') || 0, + label_height => $cgi->param('label_height') || 0, + top_text_margin => $cgi->param('top_text_margin') || 0, + left_text_margin=> $cgi->param('left_text_margin') || 0, + top_margin => $cgi->param('top_margin') || 0, + left_margin => $cgi->param('left_margin') || 0, + cols => $cgi->param('cols') || 0, + rows => $cgi->param('rows') || 0, + col_gap => $cgi->param('col_gap') || 0, + row_gap => $cgi->param('row_gap') || 0, + units => $cgi->param('units') || 'POINT', ); if ($template_id) { # if a label_id was passed in, this is an update to an existing layout $label_template = C4::Labels::Template->retrieve(template_id => $template_id); -- 2.39.5