From 27f3d0af638f3c047468d28b70a4ccc65c1f7da7 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 26 Mar 2021 16:48:24 -0300 Subject: [PATCH] Bug 14957: (QA follow-up) Clarify 'context' param This patch renames the (passed through) 'context' param for 'overlay_context'. I propose doing so, because in Koha-land 'context' has a special meaning, related to C4::Context and it reads ambigous. The patch itself is pretty trivial. Tests should pass: 1. Run: $ kshell k$ prove t/db_dependent/Biblio/MarcOverlayRules.t => SUCCESS: Tests pass 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests still pass! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Bug 14957: (follow-up) Clarify 'context' param Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Biblio.pm | 16 ++++++++-------- C4/ImportBatch.pm | 2 +- Koha/BackgroundJob/BatchUpdateBiblio.pm | 2 +- cataloguing/addbiblio.pl | 12 ++++++++---- misc/migration_tools/bulkmarcimport.pl | 2 +- misc/migration_tools/import_lexile.pl | 2 +- t/db_dependent/Biblio/MarcOverlayRules.t | 2 +- tools/batch_record_modification.pl | 10 +++++----- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 84b40b19ff..863ce496ef 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -332,7 +332,7 @@ The C<$options> argument is a hashref with additional parameters: =over 4 -=item C +=item C This parameter is forwarded to L where it is used for selecting the current rule set if MARCOverlayRules is enabled. @@ -389,13 +389,13 @@ sub ModBiblio { if ( C4::Context->preference('MARCOverlayRules') && $biblionumber && defined $options - && exists $options->{'context'} ) + && exists $options->{overlay_context} ) { $record = ApplyMarcOverlayRules( { - biblionumber => $biblionumber, - record => $record, - context => $options->{'context'}, + biblionumber => $biblionumber, + record => $record, + overlay_context => $options->{overlay_context}, } ); } @@ -3282,7 +3282,7 @@ biblionumber of old record =item C Incoming record that will be merged with old record -=item C +=item C hashref containing at least one context module and filter value on the form {module => filter, ...}. @@ -3320,8 +3320,8 @@ sub ApplyMarcOverlayRules { my $old_record = GetMarcBiblio({ biblionumber => $biblionumber }); # Skip overlay rules if called with no context - if ($old_record && defined $params->{context}) { - return Koha::MarcOverlayRules->merge_records($old_record, $incoming_record, $params->{context}); + if ($old_record && defined $params->{overlay_context}) { + return Koha::MarcOverlayRules->merge_records($old_record, $incoming_record, $params->{overlay_context}); } return $incoming_record; } diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index b6735c697d..6ae148d6d2 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -680,7 +680,7 @@ sub BatchCommitRecords { $oldxml = $old_marc->as_xml($marc_type); ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, { - context => { + overlay_context => { source => 'batchimport', categorycode => $logged_in_patron->categorycode, userid => $logged_in_patron->userid diff --git a/Koha/BackgroundJob/BatchUpdateBiblio.pm b/Koha/BackgroundJob/BatchUpdateBiblio.pm index dae46682c1..013fecbb1a 100644 --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ b/Koha/BackgroundJob/BatchUpdateBiblio.pm @@ -92,7 +92,7 @@ sub process { C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record ); my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, { - context => $args->{context}, + overlay_context => $args->{overlay_context}, }); }; if ( $error and $error != 1 or $@ ) { # ModBiblio returns 1 if everything as gone well diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 9a50ce0aa9..89a68e06f8 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -866,11 +866,15 @@ if ( $op eq "addbiblio" ) { my $oldbibitemnum; if ( $is_a_modif ) { my $member = Koha::Patrons->find($loggedinuser); - ModBiblio( $record, $biblionumber, $frameworkcode, { - context => { - source => $z3950 ? 'z39.50' : 'intranet', + ModBiblio( + $record, + $biblionumber, + $frameworkcode, + { + overlay_context => { + source => $z3950 ? 'z39.50' : 'intranet', categorycode => $member->categorycode, - userid => $member->userid + userid => $member->userid } } ); diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 7a1e800b00..5cb9b7b63b 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -450,7 +450,7 @@ RECORD: while ( ) { $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber; }; if ($update) { - eval { ModBiblio( $record, $biblionumber, $framework, { context => { source => 'bulkmarcimport' } } ) }; + eval { ModBiblio( $record, $biblionumber, $framework, { overlay_context => { source => 'bulkmarcimport' } } ) }; if ($@) { warn "ERROR: Edit biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile); diff --git a/misc/migration_tools/import_lexile.pl b/misc/migration_tools/import_lexile.pl index 7c81af971f..b63768491e 100755 --- a/misc/migration_tools/import_lexile.pl +++ b/misc/migration_tools/import_lexile.pl @@ -203,7 +203,7 @@ while ( my $row = $csv->getline_hr($fh) ) { $record->append_fields($field); } - ModBiblio( $record, $biblionumber, undef, { context => { source => 'import_lexile' } } ) unless ( $test ); + ModBiblio( $record, $biblionumber, undef, { overlay_context => { source => 'import_lexile' } } ) unless ( $test ); } } diff --git a/t/db_dependent/Biblio/MarcOverlayRules.t b/t/db_dependent/Biblio/MarcOverlayRules.t index ddd5b7e9c8..0501a1aa6a 100755 --- a/t/db_dependent/Biblio/MarcOverlayRules.t +++ b/t/db_dependent/Biblio/MarcOverlayRules.t @@ -749,7 +749,7 @@ subtest 'context option in ModBiblio is handled correctly' => sub { MARC::Field->new('500', '', '', 'a' => 'One cold bottle of beer in the fridge'), # Appended ); - ModBiblio($saved_record, $biblionumber, '', { context => { 'source' => 'test' } }); + ModBiblio($saved_record, $biblionumber, '', { overlay_context => { 'source' => 'test' } }); my $updated_record = GetMarcBiblio({ biblionumber => $biblionumber }); diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl index 7a939a1c98..f2865ca879 100755 --- a/tools/batch_record_modification.pl +++ b/tools/batch_record_modification.pl @@ -159,12 +159,12 @@ if ( $op eq 'form' ) { try { my $patron = Koha::Patrons->find( $loggedinuser ); my $params = { - mmtid => $mmtid, - record_ids => \@record_ids, - context => { - source => 'batchmod', + mmtid => $mmtid, + record_ids => \@record_ids, + overlay_context => { + source => 'batchmod', categorycode => $patron->categorycode, - userid => $patron->userid + userid => $patron->userid } }; -- 2.39.5