Bugzilla – Attachment 121405 Details for
Bug 28011
Add CLI script to update bibs from linked authority records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28011: Add CLI script to update bib headings from linked auth records
Bug-28011-Add-CLI-script-to-update-bib-headings-fr.patch (text/plain), 3.22 KB, created by
David Cook
on 2021-05-26 03:08:26 UTC
(
hide
)
Description:
Bug 28011: Add CLI script to update bib headings from linked auth records
Filename:
MIME Type:
Creator:
David Cook
Created:
2021-05-26 03:08:26 UTC
Size:
3.22 KB
patch
obsolete
>From e928b8e838a9eaff6ebc8c09d2ac013d9af843a4 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 26 May 2021 03:04:15 +0000 >Subject: [PATCH] Bug 28011: Add CLI script to update bib headings from linked > auth records >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds a script which updates bib headings from authority >records. This helps normalize the headings to remove differences >in punctuation, capitalization, etc. > >This can be useful to run after link_bibs_to_authorities.pl. > >Test plan: >1. Apply the patch >2. Go to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=192 >3. Mangle the HTML to remove the accents from 100$a and save the record >4. Note the bib record now says "By: O Cadhain, Mairtin" without the accents >5. Run the script >6. Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=192 >7. Note that the accents have been restored and it now says "By: à Cadhain, MáirtÃn" >--- > misc/update_bibs_from_authorities.pl | 68 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > create mode 100644 misc/update_bibs_from_authorities.pl > >diff --git a/misc/update_bibs_from_authorities.pl b/misc/update_bibs_from_authorities.pl >new file mode 100644 >index 0000000000..49895d9478 >--- /dev/null >+++ b/misc/update_bibs_from_authorities.pl >@@ -0,0 +1,68 @@ >+#!/usr/bin/perl >+ >+use strict; >+use warnings; >+ >+use C4::Context; >+use C4::AuthoritiesMarc qw(); >+ >+print "Fetching authority IDs\n"; >+my $auth_ids = get_used_auth_ids(); >+print "Found " . scalar @$auth_ids . " authority IDs\n"; >+foreach my $authid (@$auth_ids){ >+ print "Updating authority $authid\n"; >+ eval { >+ my $record = C4::AuthoritiesMarc::GetAuthority($authid); >+ C4::AuthoritiesMarc::merge({ mergefrom => $authid, MARCfrom => $record, mergeto => $authid, MARCto => $record }); >+ }; >+ if ($@){ >+ warn $@; >+ } >+} >+ >+sub get_used_auth_ids { >+ my @auth_ids = (); >+ my %numbers = (); >+ my $conn = C4::Context->Zconn; >+ if ($conn){ >+ $conn->option('number', '100'); >+ $conn->option('position', '1'); >+ $conn->option('stepSize', '0'); >+ my $term = 1; >+ while (1){ >+ my $rs = $conn->scan_pqf('@attr 1=8910 '.$term); >+ my $counter = 0; >+ my $size = $rs->size(); >+ if ($size){ >+ while ( $counter < $size ){ >+ ($term) = $rs->term($counter); >+ #warn "FETCHED $term"; >+ if ( ! $numbers{$term} ){ >+ $numbers{$term} = 1; >+ push(@auth_ids,$term); >+ } >+ $counter++; >+ } >+ if ($size == 1){ >+ last; >+ } >+ } >+ } >+ } >+ return \@auth_ids; >+} >+ >+=head1 NAME >+ >+update_bibs_from_authorities.pl >+ >+=head1 DESCRIPTION >+ >+This batch job finds every authority ID in the Koha-Auth-Number index, >+and then it runs a "merge", so that all bibliographic records using >+that authority will have their headings updated from the authoritative >+source record. >+ >+This is a useful job to run after link_bibs_to_authorities.pl. >+ >+=cut >-- >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 28011
: 121405