Bugzilla – Attachment 7548 Details for
Bug 7284
Authority matching algorithm improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7284 follow up: Cataloging module relinking
Bug-7284-follow-up-Cataloging-module-relinking.patch (text/plain), 8.13 KB, created by
Jared Camins-Esakov
on 2012-02-10 00:29:57 UTC
(
hide
)
Description:
Bug 7284 follow up: Cataloging module relinking
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-02-10 00:29:57 UTC
Size:
8.13 KB
patch
obsolete
>From 190912c558a55092f30d549702d9519cfa04ebe0 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Thu, 9 Feb 2012 18:31:43 -0500 >Subject: [PATCH] Bug 7284 follow up: Cataloging module relinking >Content-Type: text/plain; charset="UTF-8" > >With the first patch for bug 7284, the automatic authority linking will actually >work properly in the cataloging module. As Owen pointed out while testing the >patch, though, longtime users of Koha will not be expecting that. In keeping >with the principles of least surprise and maximum configurability, this patch >makes it possible to disable authority relinking in the cataloging module only >(i.e. leaving it enabled for future runs of link_bibs_to_authorities.pl). > >This patch addds the following syspref: >* CatalogModuleRelink - when turned on, the automatic linker will relink > headings when a record is saved in the cataloging module when LinkerRelink > is turned on, even if the headings were manually linked to a different > authority by the cataloger. When turned off (the default), the automatic > linker will not relink any headings that have already been linked when a > record is saved. > >Note that though the default behavior matches the current behavior of Koha, >it does not match the intended behavior. Libraries that want the intended >behavior rather than the current behavior will need to adjust the >CatalogModuleRelink syspref. > >Be sure to run the atomicupdate file used by this patch if you are on a dev >system: installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 > >To test this patch: >1. Run installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 >2. Set BiblioAddsAuthorities to "on." >3. Default setting of CatalogModuleRelink is "off." Leave it like that. >4. Create a record and link an authority record to an authorized field using > the authority plugin. >5. Save the record. Ensure that the heading is linked to the appropriate > authority. >6. Open the record. Change the heading manually to something else, leaving > the link. Save the record. >7. Ensure that the heading remains linked to that same authority. >8. Change CatalogModuleRelink to "on." >9. Open the record. Use the authority plugin to link that heading to the > same authority record you did earlier. >10. Save the record. Ensure that the heading is linked to the appropriate > authority. >11. Open the record. Change the heading manually to something else, leaving > the link. Save the record. >12. Ensure that the heading is no longer linked to the old authority record. >--- > C4/Biblio.pm | 17 ++++++++++------- > .../atomicupdate/bug_7284_authority_linking_pt2 | 9 +++++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../en/modules/admin/preferences/authorities.pref | 7 +++++++ > 4 files changed, 27 insertions(+), 7 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 69fd3a2..90ec975 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -487,13 +487,14 @@ sub BiblioAutoLink { > my $linker = $linker_module->new( > { 'options' => C4::Context->preference("LinkerOptions") } ); > my ( $headings_changed, undef ) = >- LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode ); >+ LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, C4::Context->preference("CatalogModuleRelink") || '' ); >+ # By default we probably don't want to relink things when cataloging > return $headings_changed; > } > > =head2 LinkBibHeadingsToAuthorities > >- my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode); >+ my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink]); > > Links bib headings to authority records by checking > each authority-controlled field in the C<MARC::Record> >@@ -501,9 +502,9 @@ object C<$marc>, looking for a matching authority record, > and setting the linking subfield $9 to the ID of that > authority record. > >-If no matching authority exists, or if multiple >-authorities match, no $9 will be added, and any >-existing one inthe field will be deleted. >+If $allowrelink is false, existing authids will never be >+replaced, regardless of the values of LinkerKeepStale and >+LinkerRelink. > > Returns the number of heading links changed in the > MARC record. >@@ -514,9 +515,11 @@ sub LinkBibHeadingsToAuthorities { > my $linker = shift; > my $bib = shift; > my $frameworkcode = shift; >+ my $allowrelink = shift; > my %results; > require C4::AuthoritiesMarc; > >+ $allowrelink = 1 unless defined $allowrelink; > my $num_headings_changed = 0; > foreach my $field ( $bib->fields() ) { > my $heading = C4::Heading->new_from_bib_field( $field, $frameworkcode ); >@@ -525,7 +528,7 @@ sub LinkBibHeadingsToAuthorities { > # check existing $9 > my $current_link = $field->subfield('9'); > >- if ( defined $current_link && !C4::Context->preference('LinkerRelink') ) >+ if ( defined $current_link && (!$allowrelink || !C4::Context->preference('LinkerRelink')) ) > { > $results{'linked'}->{ $heading->display_form() }++; > next; >@@ -543,7 +546,7 @@ sub LinkBibHeadingsToAuthorities { > } > else { > if ( defined $current_link >- && C4::Context->preference('LinkerKeepStale') ) >+ && (!$allowrelink || C4::Context->preference('LinkerKeepStale')) ) > { > $results{'fuzzy'}->{ $heading->display_form() }++; > } >diff --git a/installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 b/installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 >new file mode 100755 >index 0000000..6c2bdfb >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 >@@ -0,0 +1,9 @@ >+#! /usr/bin/perl >+use strict; >+use warnings; >+use C4::Context; >+my $dbh = C4::Context->dbh; >+$dbh->do( >+"INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo');" >+); >+print "Upgrade done (Configured bug 7284, added the )\n"; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index f0ac5df5..1a29493 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -339,3 +339,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >index 953c97d..27dc9d5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >@@ -65,3 +65,10 @@ Authorities: > yes: Do > no: "Do not" > - keep existing links to authority records for headings where the linker is unable to find a match. >+ - >+ - pref: CatalogModuleRelink >+ default: no >+ choices: >+ yes: Do >+ no: "Do not" >+ - automatically relink headings that have previously been linked when saving records in the cataloging module. >-- >1.7.2.5
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 7284
:
7083
|
7084
|
7085
|
7086
|
7087
|
7091
|
7266
|
7323
|
7457
|
7548
|
7688
|
7714
|
7788
|
7829
|
7938
|
8060
|
8066
|
8137
|
8862
|
8864