Bugzilla – Attachment 170800 Details for
Bug 37675
MARC basic editor loses data for records with thousands of the same field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37675: Use UUID
Bug-37675-Use-UUID.patch (text/plain), 3.51 KB, created by
Jonathan Druart
on 2024-08-28 08:31:08 UTC
(
hide
)
Description:
Bug 37675: Use UUID
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-08-28 08:31:08 UTC
Size:
3.51 KB
patch
obsolete
>From ed4dc50c933d3923e4644f4d1c48237497f140f9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 28 Aug 2024 10:30:30 +0200 >Subject: [PATCH] Bug 37675: Use UUID > >--- > Koha/UI/Form/Builder/Biblio.pm | 14 +++++--------- > cataloguing/addbiblio.pl | 18 ++++++------------ > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 2 +- > 3 files changed, 12 insertions(+), 22 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Biblio.pm b/Koha/UI/Form/Builder/Biblio.pm >index 36865ea3c82..4e596f731ff 100644 >--- a/Koha/UI/Form/Builder/Biblio.pm >+++ b/Koha/UI/Form/Builder/Biblio.pm >@@ -16,6 +16,7 @@ package Koha::UI::Form::Builder::Biblio; > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use UUID; > use C4::Context; > use C4::ClassSource qw( GetClassSources ); > use Koha::DateUtils qw( dt_from_string ); >@@ -393,15 +394,10 @@ sub build_authorized_values_list { > > sub create_key { > my ($self) = @_; >- my $unique_keys = $self->{unique_keys}; >- my $max_num = 10000000; >- #TODO: Note this could lead to a near infinite loop >- while (my $value = int(rand($max_num)) ){ >- if ( ! $unique_keys->{$value} ){ >- $unique_keys->{$value} = 1; >- return $value; >- } >- } >+ my ($uuid, $key); >+ UUID::generate($uuid); >+ UUID::unparse($uuid, $key); >+ return $key; > } > > 1; >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 9a5964b7ac0..3d5179ab942 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -23,6 +23,7 @@ use Modern::Perl; > use CGI; > use POSIX qw( strftime ); > use Try::Tiny qw(catch try); >+use UUID; > > use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user haspermission ); >@@ -183,15 +184,10 @@ sub MARCfindbreeding { > =cut > > sub CreateKey { >- my ($unique_keys) = @_; >- my $max_num = 10000000; >- #TODO: Note this could lead to a near infinite loop >- while (my $value = int(rand($max_num)) ){ >- if ( ! $unique_keys->{$value} ){ >- $unique_keys->{$value} = 1; >- return $value; >- } >- } >+ my ($uuid, $key); >+ UUID::generate($uuid); >+ UUID::unparse($uuid, $key); >+ return $key; > } > > =head2 GetMandatoryFieldZ3950 >@@ -236,8 +232,6 @@ sub format_indicator { > sub build_tabs { > my ( $template, $record, $dbh, $encoding,$input ) = @_; > >- my $unique_keys = {}; >- > # fill arrays > my @loop_data = (); > my $tag; >@@ -423,7 +417,7 @@ sub build_tabs { > important => $tagslib->{$tag}->{important}, > subfield_loop => \@subfields_data, > fixedfield => $tag < 10?1:0, >- random => CreateKey($unique_keys), >+ random => CreateKey(), > ); > if ($tag >= 10){ # no indicator for 00x tags > $tag_data{indicator1} = format_indicator($field->indicator(1)), >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index ed0ac18b794..b3e455e1ec6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -506,7 +506,7 @@ function UnCloneField(index) { > * This function create a random number > */ > function CreateKey(){ >- return parseInt(Math.random() * 10000000); >+ return crypto.randomUUID(); > } > > /* Functions developed for additem.tt */ >-- >2.34.1
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 37675
:
170470
|
170580
|
170764
|
170795
|
170796
| 170800