[Koha-bugs] [Bug 29392] Add plugin hooks before merging biblios or authorities
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Mar 18 14:47:40 CET 2024
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29392
Martin Renvoize <martin.renvoize at ptfs-europe.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #127217|0 |1
is obsolete| |
--- Comment #7 from Martin Renvoize <martin.renvoize at ptfs-europe.com> ---
Created attachment 163329
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163329&action=edit
Bug 29392: Add plugin hooks before merging biblios or authorities
Hooks are called 'before_biblio_action' and 'before_authority_action'
and they both take an 'action' parameter whose value is 'merge'.
Other parameters include the record id (biblionumber or authid), the
object itself (Koha::Biblio or Koha::Authority), the MARC::Record about
to be saved (so plugins can modify it), and the list of record ids that
will be deleted after the merge.
Test plan:
1. Create a plugin with these two methods. For instance:
sub before_biblio_action {
my ($self, $args) = @_;
my $action = $args->{action};
return unless $action eq 'merge';
my $record = $args->{record};
my $merged_biblio_ids = $args->{merged_biblio_ids};
if ($record && $merged_biblio_ids) {
my @fields = map {
MARC::Field->new('035', ' ', ' ', 'z' => $_)
} @$merged_biblio_ids;
$record->insert_fields_ordered(@fields);
}
}
sub before_authority_action {
my ($self, $args) = @_;
my $action = $args->{action};
return unless $action eq 'merge';
my $record = $args->{record};
my $merged_authority_ids = $args->{merged_authority_ids};
if ($record && $merged_authority_ids) {
my @fields = map {
MARC::Field->new('035', ' ', ' ', 'z' => $_)
} @$merged_authority_ids;
$record->insert_fields_ordered(@fields);
}
}
This will copy the identifier of deleted records inside 035$z of the
final record.
(035$z is for "Canceled/invalid system control number")
2. Add the plugin path to your $KOHA_CONF
3. Run misc/devel/install_plugins.pl. It should say:
Installed <YOUR_PLUGIN_NAME> version <YOUR_PLUGIN_VERSION>
4. Apply patch and restart starman
5. Create two or more biblios with the same title. Make sure they are
indexed in your search engine.
6. Search for them. In the results check their corresponding boxes and
click on "Edit -> Merge records"
7. Merge them and verify that your plugin code was called. If you used
the example above, verify that it added a 035$z for each deleted
record.
8. Do the same for authorities
Signed-off-by: Martin Renvoize <martin.renvoize at ptfs-europe.com>
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list