Bugzilla – Attachment 168352 Details for
Bug 31109
Prevent overwriting bibliographic records in case of simultaneous modification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31109: Koha::Util::Misc - utility class with miscellaneous routines
Bug-31109-KohaUtilMisc---utility-class-with-miscel.patch (text/plain), 4.33 KB, created by
Janusz Kaczmarek
on 2024-07-02 11:53:03 UTC
(
hide
)
Description:
Bug 31109: Koha::Util::Misc - utility class with miscellaneous routines
Filename:
MIME Type:
Creator:
Janusz Kaczmarek
Created:
2024-07-02 11:53:03 UTC
Size:
4.33 KB
patch
obsolete
>From 07a650bfd54a58adaf6cdb37932662d1622d8bc1 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Mon, 3 Jun 2024 12:30:34 +0000 >Subject: [PATCH] Bug 31109: Koha::Util::Misc - utility class with > miscellaneous routines > >New module with only one function now: digest -- to calculate a md5_hex >digest of the given argument (any Perl data structure). >--- > Koha/Util/Misc.pm | 144 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 144 insertions(+) > create mode 100644 Koha/Util/Misc.pm > >diff --git a/Koha/Util/Misc.pm b/Koha/Util/Misc.pm >new file mode 100644 >index 0000000000..87e42ae01e >--- /dev/null >+++ b/Koha/Util/Misc.pm >@@ -0,0 +1,144 @@ >+package Koha::Util::Misc; >+ >+# Copyright 2024 Koha Development Team >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Digest::MD5 qw( md5_hex ); >+use Sereal::Encoder qw( encode_sereal ); >+use Koha::Biblios; >+use Koha::MetadataRecord; >+use C4::Biblio qw( GetFrameworkCode GetMarcStructure GetMarcFromKohaField ); >+ >+=head1 NAME >+ >+Koha::Util::Misc - utility class with miscellaneous routines >+ >+=head1 FUNCTIONS >+ >+=head2 digest >+ >+my $digest = Koha::Util::Misc::digest( $data_structure ) >+ >+Calculates a md5_hex digest of the given argument (any Perl data structure). >+ >+=head3 Returns: >+ >+=over 4 >+ >+=item C<$digest> >+ >+calculated digest >+ >+=back >+ >+=cut >+ >+sub digest { >+ my $data = shift; >+ return md5_hex( >+ encode_sereal( >+ ( ref $data eq '' ) ? \$data : $data, >+ { sort_keys => 1 } >+ ) >+ ); >+} >+ >+=head2 prepare_mid_air_collision_merge >+ >+my ( $records, $framework_database ) = prepare_mid_air_collision_merge( $data ) >+ >+Prepares data for merging two versions of a bibliographic record in case of >+concurrent modification made. >+ >+=head3 Parameters: >+ >+=over 4 >+ >+=item C<$data> >+ >+in $data you pass biblionumber of the modified bibliographic record and >+its modified version in MARC::Record object >+ >+=back >+ >+=head3 Returns: >+ >+=over 4 >+ >+=item C<$records> >+ >+a data structure suitable for 'records' parameter for cataloguing/merge.tt >+template >+ >+ >+=item C<$framework_database> >+ >+a template code of the database version of the record needed for >+cataloguing/merge.tt template ('framework' parameter) >+ >+=back >+ >+=cut >+ >+sub prepare_mid_air_collision_merge { >+ my $data = shift; >+ my $biblionumber = $data->{biblionumber}; >+ my $modified_record = $data->{modified_record}; >+ >+ my $framework_database = GetFrameworkCode($biblionumber); >+ >+ # Getting MARC Structure >+ my $tagslib = GetMarcStructure( 1, $framework_database ); >+ >+ my $marcflavour = lc( C4::Context->preference('marcflavour') ); >+ >+ # Creating a loop for display >+ my @records; >+ >+ for my $i ( 0 .. 1 ) { >+ my $biblio; >+ my $marcrecord; >+ my $template_record; >+ if ( $i == 0 ) { #database version >+ $biblio = Koha::Biblios->find($biblionumber); >+ $marcrecord = $biblio->record; >+ $template_record->{reference} = 1; >+ $template_record->{recordid} = $biblionumber; >+ } else { #modified version >+ $marcrecord = $modified_record; >+ $template_record->{recordid} = -1; # NOTE for the modified version >+ } >+ >+ my $recordObj = Koha::MetadataRecord->new( { 'record' => $marcrecord, schema => $marcflavour } ); >+ $template_record->{record} = $marcrecord; >+ $template_record->{display} = $recordObj->createMergeHash($tagslib); >+ push @records, $template_record; >+ } >+ return ( \@records, $framework_database ); >+} >+ >+1; >+__END__ >+ >+=head1 AUTHOR >+ >+Koha Development Team <https://koha-community.org/> >+ >+Janusz Kaczmarek <januszop@gmail.com> >+ >+=cut >-- >2.39.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 31109
:
139046
|
167192
|
167373
|
167374
|
167375
|
167415
|
167416
|
167417
|
167436
|
167437
|
167438
|
167439
|
167492
|
167493
|
167494
|
168352
|
168353
|
168354
|
168472
|
168473
|
168474