From 12ed7a654b01c0eefb05c14ae8f5d1ddbac4edb7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 7 Aug 2019 20:16:00 -0500 Subject: [PATCH] Bug 23309: Use Koha::MarcSubfieldStructures to create to subfields It will fix the insert of new subfields with SQL strict modes DBD::mysql::st execute failed: Incorrect integer value: '' for column 'hidden' at row 1 [for Statement " Test plan: - Turn the config strict_sql_modes ON - Add a new subfield to a field Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize (cherry picked from commit 144e753da65cafa3c4291eec701222784ec0893f) Signed-off-by: Fridolin Somers (cherry picked from commit 611bea77ec1c125dbfce5c4b40681fcc6fab9520) Signed-off-by: Lucas Gass --- admin/marc_subfields_structure.pl | 51 +++++++++++++------------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 25196491b1..cdefc25884 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -233,14 +233,6 @@ if ( $op eq 'add_form' ) { elsif ( $op eq 'add_validate' ) { my $dbh = C4::Context->dbh; $template->param( tagfield => "$input->param('tagfield')" ); -# my $sth = $dbh->prepare( -# "replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue) -# values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" -# ); - my $sth_insert = $dbh->prepare(qq{ - insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue,maxlength) - values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) - }); my $sth_update = $dbh->prepare(qq{ update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?, link=?, defaultvalue=?, maxlength=? where tagfield=? and tagsubfield=? and frameworkcode=? @@ -312,30 +304,31 @@ elsif ( $op eq 'add_validate' ) { my $rec = Koha::MarcSubfieldStructures->find( q{}, $tagfield, $tagsubfield ); $kohafield = $rec->kohafield if $rec; } - $sth_insert->execute( - $tagfield, - $tagsubfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $kohafield, - $tab, - $seealso, - $authorised_value, - $authtypecode, - $value_builder, - $hidden, - $isurl, - $frameworkcode, - $link, - $defaultvalue, - $maxlength, - ); + Koha::MarcSubfieldStructure->new( + { + tagfield => $tagfield, + tagsubfield => $tagsubfield, + liblibrarian => $liblibrarian, + libopac => $libopac, + repeatable => $repeatable, + mandatory => $mandatory, + kohafield => $kohafield, + tab => $tab, + seealso => $seealso, + authorised_value => $authorised_value, + authtypecode => $authtypecode, + value_builder => $value_builder, + hidden => $hidden, + isurl => $isurl, + frameworkcode => $frameworkcode, + link => $link, + defaultvalue => $defaultvalue, + maxlength => $maxlength, + } + )->store; } } } - $sth_insert->finish; $sth_update->finish; $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); -- 2.39.5