Bug 27968: Fix framework import if isurl has an incorrect value

If isurl is set to undef in the DB, it will be exported as an empty
string, which is an invalid value for isurl (int)

Incorrect integer value: '' for column 'isurl'

Test plan:
Export framework structure in CSV and ODS, then reimport it and check that
all the subfields are important correctly

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 01f0e04172)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5b4dd72d3a)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
(cherry picked from commit 08c2408a3d)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Jonathan Druart 2021-03-17 09:18:48 +01:00 committed by Victor Grousset/tuxayo
parent 3ebf34acb1
commit 5bb2b5bafc
2 changed files with 10 additions and 2 deletions

View File

@ -977,6 +977,9 @@ sub _import_table_csv
} elsif ($fields->[$j] eq 'frameworkcode' && $value ne $frameworkcode) {
$dataFields{$fields->[$j]} = $frameworkcode;
push @values, $frameworkcode;
} elsif ($fields->[$j] eq 'isurl' && defined $value && $value eq q{}) {
$dataFields{$fields->[$j]} = undef;
push @values, undef;
} else {
$dataFields{$fields->[$j]} = $value;
push @values, $value;
@ -1094,7 +1097,12 @@ sub _getDataFields
if ($ok) {
$data //= '';
$data = '' if ($data eq '#');
$data = $frameworkcode if ($fields->[$i] eq 'frameworkcode');
if ( $fields->[$i] eq 'frameworkcode' ) {
$data = $frameworkcode;
}
elsif ( $fields->[$i] eq 'isurl' ) {
$data = undef if defined $data && $data eq q{};
}
$dataFields->{$fields->[$i]} = $data;
push @dataFieldsA, $data;
$i++;

View File

@ -7,7 +7,7 @@
"#-#","#-#","#-#","#-#","#-#","#-#","#-#"
"tagfield","tagsubfield","liblibrarian","libopac","repeatable","mandatory","kohafield","tab","authorised_value","authtypecode","value_builder","isurl","hidden","frameworkcode","seealso","link","defaultvalue","maxlength"
"000","@","fixed length control field","fixed length control field","0","1","","0","","","marc21_leader.pl","0","0","","","","","24"
"000","@","fixed length control field","fixed length control field","0","1","","0","","","marc21_leader.pl","","0","","","","","24"
"001","@","control field","control field","0","0","","0","","","","0","0","","","","","9999"
"003","@","control field","control field","0","1","","0","","","marc21_orgcode.pl","0","0","","","","","9999"
"005","@","control field","control field","0","1","","0","","","marc21_field_005.pl","0","0","","","","","9999"

Can't render this file because it has a wrong number of fields in line 9.