From 2f266d94be06af73e72a807d9408136278e8fed4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 17 Dec 2014 10:43:34 +0100 Subject: [PATCH] Bug 13465: Correct the field prefix ambiguity This is introduced by Bug 12874. Without this patch, it's not possible to clear (set to an empty string) an item field. This appended for field linked to an AV list but even if it's not. The regex tried to prefix 'my_field' with 'items.' to have 'items.my_field'. It wanted to take care of the case where the prefix already exists (Actually only 1: 'items.cn_source'). The regex is changed to: "add the prefix only if the string does not contain a dot". Moreover an ambiguity existed on the prefix: in marc_subfield_structure, the kohafield is prefixed, but not in the key of the hash sent to ModItemFromMarc. Test plan: - edit an item, set a status that is controlled by an authorized value examples tested: damaged, not for loan - check the status saved correctly - edit the item again, reset the status to empty - check the status saved correctly - edit the item again, reset fields, edit fields - check the fields saved correctly Signed-off-by: Mirko Tietgen Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Items.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index e63ef1bcd0..33143a5e5f 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -482,11 +482,12 @@ sub _build_default_values_for_mod_marc { withdrawn => 0, }; while ( my ( $field, $default_value ) = each %$default_values ) { - $field =~ s|[^\.]*\.?(.*)|items.$1|; + my $kohafield = $field; + $kohafield =~ s|^([^\.]+)$|items.$1|; $default_values_for_mod_from_marc{$frameworkcode}{$field} = $default_value if C4::Koha::IsKohaFieldLinked( - { kohafield => $field, frameworkcode => $frameworkcode } ); + { kohafield => $kohafield, frameworkcode => $frameworkcode } ); } return $default_values_for_mod_from_marc{$frameworkcode}; } -- 2.39.5