Bug 39560: For authorities hidden fields (but present in the record) will be lost when editing and saving such a record

If a subfield is present in the authority record, but this subfield is
marked as 'Hide all', then if you edit and save such a record, the
data from hidden fields wil be lost forever.  This behavior differs
from bibliographic records editor, when even if a subfield is hidden
(not active) in the editor it will be activated and present in the
editor if present in the record.

The problem affect above all records imported from external agencies.

Test plan:
==========
1. Have any authority record. Note one present subfield (e.g. 100 $d).
2. Modify the record framework for this type of record
   (/cgi-bin/koha/admin/authtypes.pl), marking the subfield 'Hide all'.
3. Open the record in the editor and save.
4. Re-enable the subfield in the framework, marking it as 'Show all' now.
5. Reopen the record in the editor. Note that the previous content of
   the subfield you played with is gone. Enter any new value and save.
6. Apply the patch ; restart all.
7. Repeat p. 2, i.e. hide the subfield again. Open the record in
   the editor. You should see the content of the hidden field as you
   would for a bibliographic record with a subfield hidden in the editor
   but present in a record. (Note also that the content of this subfield
   is visible in record view).
8. Open the editor with an empty record (New authority) of the type
   in question. Control that the subfield is hidden (not accessible)
   for a new record.

BTW Note that the "hidden" but present subfields are visible in OPAC,
but not in the staff interface *before* applying the patch. The patch
changes nothing for OPAC.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Janusz Kaczmarek 2025-04-04 09:04:50 +00:00 committed by Katrin Fischer
parent 20b600d450
commit 5518fe490a
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 6 additions and 6 deletions

View File

@ -161,7 +161,7 @@ sub create_input {
}
$subfield_data{visibility} = "display:none;"
if ( $tagslib->{$tag}->{$subfield}->{hidden} and $value ne ''
if ( $tagslib->{$tag}->{$subfield}->{hidden} and $value eq ''
or ( $value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory} ) );
# it's an authorised field
@ -381,7 +381,7 @@ sub build_tabs {
$subfield = '@';
}
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9' && !$value;
push(
@subfields_data,
&create_input(
@ -396,7 +396,10 @@ sub build_tabs {
my $value = $subfields[$subfieldcount][1];
next if ( length $subfield != 1 );
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
next
if $tagslib->{$tag}->{$subfield}->{hidden}
&& $subfield ne '9'
&& ( !$value || $tag eq '942' );
push(
@subfields_data,
&create_input(

View File

@ -99,7 +99,6 @@ sub build_tabs {
if ( $field->tag() < 10 ) {
next
if ( $tagslib->{ $field->tag() }->{'@'}->{tab} ne $tabloop );
next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} );
my %subfield_data;
$subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib};
$subfield_data{marc_value} = $field->data();
@ -114,8 +113,6 @@ sub build_tabs {
$subf[$i][0] = "@" unless defined $subf[$i][0];
next
if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{tab} ne $tabloop );
next
if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} );
my %subfield_data;
$subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl} ) {