Bugzilla – Attachment 96777 Details for
Bug 24294
Creating an order with ACQ framework using 00x fields doesn't work with default value
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24294: Add default value support for control fields in ACQ framework
Bug-24294-Add-default-value-support-for-control-fi.patch (text/plain), 3.68 KB, created by
Katrin Fischer
on 2020-01-02 22:44:55 UTC
(
hide
)
Description:
Bug 24294: Add default value support for control fields in ACQ framework
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-01-02 22:44:55 UTC
Size:
3.68 KB
patch
obsolete
>From 49ade3a51ae842d7c802584e435a935679d23816 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 2 Jan 2020 12:09:27 +0100 >Subject: [PATCH] Bug 24294: Add default value support for control fields in > ACQ framework > >When trying to add an order using the ACQ framework with a 008@ tag, >Koha explodes: > >Control fields (generally, just tags below 010) do not have subfields, >use data() at /home/vagrant/kohaclone/C4/Acquisition.pm line 3272. > >Test plan: >Set a default value for a control field in the ACQ framework >Turn on UseACQFrameworkForBiblioRecords >Create a new order from a new record >The default value should be displayed >Save >=> No crash > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Acquisition.pm | 24 ++++++++++++++++------ > t/db_dependent/Acquisition/FillWithDefaultValues.t | 9 ++++++++ > 2 files changed, 27 insertions(+), 6 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index fcd590df79..fb644edc1d 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -3269,18 +3269,30 @@ sub FillWithDefaultValues { > my @fields = $record->field($tag); > if (@fields) { > for my $field (@fields) { >- unless ( defined $field->subfield($subfield) ) { >+ if ( $field->is_control_field ) { >+ $field->update($defaultvalue) if not defined $field->data; >+ } >+ elsif ( not defined $field->subfield($subfield) ) { > $field->add_subfields( > $subfield => $defaultvalue ); > } > } > } > else { >- $record->insert_fields_ordered( >- MARC::Field->new( >- $tag, '', '', $subfield => $defaultvalue >- ) >- ); >+ if ( $tag < 10 ) { # is_control_field >+ $record->insert_fields_ordered( >+ MARC::Field->new( >+ $tag, $defaultvalue >+ ) >+ ); >+ } >+ else { >+ $record->insert_fields_ordered( >+ MARC::Field->new( >+ $tag, '', '', $subfield => $defaultvalue >+ ) >+ ); >+ } > } > } > } >diff --git a/t/db_dependent/Acquisition/FillWithDefaultValues.t b/t/db_dependent/Acquisition/FillWithDefaultValues.t >index f70ae1e0b6..8a09fdaf66 100755 >--- a/t/db_dependent/Acquisition/FillWithDefaultValues.t >+++ b/t/db_dependent/Acquisition/FillWithDefaultValues.t >@@ -19,6 +19,11 @@ $biblio_module->mock( > 'GetMarcStructure', > sub { > { >+ # default for a control field >+ '008' => { >+ x => { defaultvalue => $default_x }, >+ }, >+ > # default value for an existing field > '245' => { > c => { defaultvalue => $default_author }, >@@ -40,6 +45,10 @@ my $record = MARC::Record->new; > $record->leader('03174nam a2200445 a 4500'); > my @fields = ( > MARC::Field->new( >+ '008', '1', ' ', >+ '@' => '120829t20132012nyu bk 001 0ceng', >+ ), >+ MARC::Field->new( > 100, '1', ' ', > a => 'Knuth, Donald Ervin', > d => '1938', >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24294
:
96732
|
96777
|
99582
|
99583