Bugzilla – Attachment 161215 Details for
Bug 30047
Add a field to auth_header to record main heading as text string
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30047: Add new heading field to auth_header table
Bug-30047-Add-new-heading-field-to-authheader-tabl.patch (text/plain), 4.61 KB, created by
Biblibre Sandboxes
on 2024-01-19 15:37:51 UTC
(
hide
)
Description:
Bug 30047: Add new heading field to auth_header table
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2024-01-19 15:37:51 UTC
Size:
4.61 KB
patch
obsolete
>From df363eaec335bc88b4fae319434935b96a283212 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 19 Jan 2024 14:20:19 +0000 >Subject: [PATCH] Bug 30047: Add new heading field to auth_header table > >This patch adds a new heading field containing the display form of the authority record > >NOTE: If trying to save an auhority in the 'DEFAULT' framework, you will get an error, you should not be >using DEFAULT for authorities and we should remove from the list on another bug > >To test: >1 - Apply patches >2 - Update database >3 - Restart all >4 - Create a new authority, save. >5 - Do this for various types >6 - View the db records: > SELECT * FROM auth_header\G >7 - Note new heading field is populated correctly >8 - Edit your new authorities >9 - Confirm the heading field is updated correctly >10 - Import some authorities and confirm heading generated correctly >11 - Import auth via Z39.50 and confirm heading generated correctly > >Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> >--- > C4/AuthoritiesMarc.pm | 18 ++++++++++++++++-- > C4/Heading/MARC21.pm | 3 +-- > Koha/Authority.pm | 28 ++++++++++++++++++++++++++++ > 3 files changed, 45 insertions(+), 4 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 6af31ec6b9..a93e387149 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -674,7 +674,13 @@ sub AddAuthority { > $action = 'create'; > > # Save a blank record, get authid >- $authority = Koha::Authority->new( { datecreated => \'NOW()', marcxml => '' } )->store(); >+ $authority = Koha::Authority->new( >+ { >+ datecreated => \'NOW()', >+ marcxml => '', >+ authtypecode => $authtypecode >+ } >+ )->store(); > $authority->discard_changes(); > $authid = $authority->authid; > logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); >@@ -687,9 +693,17 @@ sub AddAuthority { > $record->delete_field( $record->field('001') ); > $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); > >+ my $heading = $authority->heading_object( { record => $record } ); >+ > # Update > $authority->update( >- { authtypecode => $authtypecode, marc => $record->as_usmarc, marcxml => $record->as_xml_record($format) } ); >+ { >+ authtypecode => $authtypecode, >+ marc => $record->as_usmarc, >+ marcxml => $record->as_xml_record($format), >+ heading => $heading->display_form, >+ } >+ ); > > unless ($skip_record_index) { > my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); >diff --git a/C4/Heading/MARC21.pm b/C4/Heading/MARC21.pm >index e8d6f90553..cb422d5c11 100644 >--- a/C4/Heading/MARC21.pm >+++ b/C4/Heading/MARC21.pm >@@ -201,7 +201,7 @@ my $auth_heading_fields = { > main_entry => 1 > }, > '151' => { >- auth_type => 'GEOG_NAME', >+ auth_type => 'GEOGR_NAME', > subfields => 'avxyz68', > main_entry => 1 > }, >@@ -344,7 +344,6 @@ sub parse_heading { > _get_search_heading( $field, $field_info->{'subfields'} ); > my $display_heading = > _get_display_heading( $field, $field_info->{'subfields'} ); >- > return ( $auth_type, $thesaurus, $search_heading, $display_heading, > 'exact' ); > } >diff --git a/Koha/Authority.pm b/Koha/Authority.pm >index 509d2f9ae7..cc29c80207 100644 >--- a/Koha/Authority.pm >+++ b/Koha/Authority.pm >@@ -24,6 +24,8 @@ use base qw(Koha::Object); > use Koha::Authority::ControlledIndicators; > use Koha::SearchEngine::Search; > >+use C4::Heading qw( new_from_field ); >+ > =head1 NAME > > Koha::Authority - Koha Authority Object class >@@ -61,6 +63,32 @@ sub linked_biblionumbers { > return Koha::Authorities->linked_biblionumbers( $params ); > } > >+=head3 heading_object >+ >+ Routine to return the C4::Heading object for this authority >+ >+=cut >+ >+sub heading_object { >+ >+ my ( $self, $params ) = @_; >+ my $record = $params->{record}; >+ >+ if ( !$self->{_report_tag} ) { >+ my $authtype = Koha::Authority::Types->find( $self->authtypecode ); >+ return {} if !$authtype; # very exceptional >+ $self->{_report_tag} = $authtype->auth_tag_to_report; >+ } >+ >+ if ( !$record ) { >+ $record = $self->record; >+ } >+ my $field = $record->field( $self->{_report_tag} ); >+ my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading >+ return $heading; >+ >+} >+ > =head3 controlled_indicators > > Some authority types control the indicators of some corresponding >-- >2.30.2
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 30047
:
161208
|
161209
|
161210
|
161211
|
161213
|
161214
|
161215
|
161216
|
166522
|
166523
|
166524
|
166525
|
166644