Bug 23532

Summary: AutoCreateAuthorities create authority only headings
Product: Koha Reporter: George Veranis <gveranis>
Component: CatalogingAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: a.roussos, m.de.rooy, marjorie.barry-vila, patrick.robitaille, phil
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description George Veranis 2019-09-03 10:56:19 UTC
The problem: 
We have enable AutoCreateAuthorities and also enable BiblioAddsAuthorities
and when we insert values for tag 650 , we get authorities only with 150$a filled and not other subfields. 

I found that on C4/Biblio.pm lines 549 - 555

 map {
                        $authfield->add_subfields( $_->[0] => $_->[1] )
                          if ( $_->[0] =~ /[A-z]/ && $_->[0] ne "a"
                            && C4::Heading::valid_bib_heading_subfield(
                                $authority_type->auth_tag_to_report, $_->[0] )
                            );
                    } $field->subfields();

Koha try to copy subfields to the new authority record. 
BUT the condition  

C4::Heading::valid_bib_heading_subfield(
                                $authority_type->auth_tag_to_report, $_->[0])

return false. Because the  $authority_type->auth_tag_to_report has value of 150 and not 650 as file C4/Heading/MARC21.pm declared. 

if we set on file C4/Heading/MARC21.pm also the value 
 '150' => { auth_type => 'TOPIC_TERM', subfields => 'abvxyz', subject => 1 },

(valid based on https://github.com/Koha-Community/Koha/blob/master/installer/data/mysql/en/marcflavour/marc21/mandatory/authorities_normal_marc21.sql)

then it works , but I am not sure if it is valid to set there new fields. 

or better solution could be $authority_type->auth_tag_to_report take right value in condition.

Could anyone propose the best solution ? 

Thanks, 
George Veranis
Comment 1 Andreas Roussos 2021-02-12 14:20:16 UTC
I managed to reproduce this: the current master I used was aa178bc.

In C4/Heading/MARC21.pm, the variable $bib_heading_fields is hardcoded.
Under the 'DATA STRUCTURES' heading there's actually a comment that
reads: "FIXME - this should be moved to a configuration file."

C4/Heading/UNIMARC.pm uses a different approach, where the same
variable is populated from the results of a SELECT statement on the
marc_subfield_structure table.

In my case, to work around this problem, I had to do the following:

1) modify C4/Heading/UNIMARC.pm as per below:

-    '650' => { auth_type => 'TOPIC_TERM', subfields => 'abvxyz', subject => 1 },
+    '650' => { auth_type => 'TOPIC_TERM', subfields => 'abcdegvxyz', subject => 1 },

2) add subfields $c/$d/$e to the MARC framework subfield structure
of field 150 for the TOPIC_TERM authority type.

Then, all subfields entered in tag 650 while adding a biblio in the
Cataloging module were copied to tag 150 of the new authority that
was created automatically.

But, what should we do to fix this issue for the general case?

Could we follow the same approach as for UNIMARC, and populate the
$bib_heading_fields variable from SQL data?

Or do we need a separate configuration file for this?
Comment 2 Andreas Roussos 2023-07-31 21:42:07 UTC
(In reply to Andreas Roussos from comment #1)
> 1) modify C4/Heading/UNIMARC.pm as per below:
I just realised I made a typo there, what I meant to say was:
1) modify C4/Heading/MARC21.pm as per below:
Comment 3 Phil Ringnalda 2024-02-23 19:03:35 UTC
Comment 0 was fixed by bug 24421

For comment 1, e should not be included just like it is not included for name headings: there's one Eastwood, Clint, 1930- whether he was $eactor or $edirector or $eactor, director for a particular biblio record. And for 150, the MARC21 Authority format doesn't define any of c d or e which is correct for e (it's only defined in authorities for use as the relationship between a name and a work in name-title headings) but rather odd for c and d.

So there's no reason why there shouldn't be a bug for adding g to the list of 650 subfields, but adding c and d should start with a spec proposal, https://www.loc.gov/marc/faq.html#changes

*** This bug has been marked as a duplicate of bug 24421 ***