Bugzilla – Attachment 46619 Details for
Bug 15572
Authority creation fails when authid is linked to 001 field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6657: Follow-up to fix error on authority creation
Bug-6657-Follow-up-to-fix-error-on-authority-creat.patch (text/plain), 5.81 KB, created by
Frédéric Demians
on 2016-01-13 20:56:51 UTC
(
hide
)
Description:
Bug 6657: Follow-up to fix error on authority creation
Filename:
MIME Type:
Creator:
Frédéric Demians
Created:
2016-01-13 20:56:51 UTC
Size:
5.81 KB
patch
obsolete
>From ed9bed69615e515fd81fd94804da29b344157251 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= <f.demians@tamil.fr> >Date: Tue, 12 Jan 2016 11:53:11 +0100 >Subject: [PATCH] Bug 6657: Follow-up to fix error on authority creation > >Bug 6657 modified the way C4::Biblio::TransformHtmlToMarc operates in order to >solve an issue occuring during biblio record cataloguing. But this function is >also used by authorities cataloguing, and the code in this case is irrelevante. >This followup allows to distinguish for which kind of record >TransformHtmlToMarc is called: biblio/authority. > >A bug appears in authority creation without this patch in some circunstances: >when authid is linked to 001 field. > >http://bugs.koha-community.org/show_bug.cgi?id=15572 >--- > C4/Biblio.pm | 16 +++++++++++----- > authorities/authorities.pl | 2 +- > authorities/merge.pl | 2 +- > cataloguing/addbiblio.pl | 4 ++-- > cataloguing/merge.pl | 2 +- > 5 files changed, 16 insertions(+), 10 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 03ccec9..f08fc37 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2496,7 +2496,7 @@ sub _default_ind_to_space { > =cut > > sub TransformHtmlToMarc { >- my $cgi = shift; >+ my ($cgi, $isbiblio) = @_; > > my @params = $cgi->param(); > >@@ -2517,7 +2517,9 @@ sub TransformHtmlToMarc { > my $record = MARC::Record->new(); > my $i = 0; > my @fields; >- my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' ); >+ my ($biblionumbertagfield, $biblionumbertagsubfield) = (-1, -1); >+ ($biblionumbertagfield, $biblionumbertagsubfield) = >+ &GetMarcFromKohaField( "biblio.biblionumber", '' ) if $isbiblio; > #FIXME This code assumes that the CGI params will be in the same order as the fields in the template; this is no absolute guarantee! > while ( $params[$i] ) { # browse all CGI params > my $param = $params[$i]; >@@ -2541,8 +2543,10 @@ sub TransformHtmlToMarc { > > if ( $tag < 10 ) { # no code for theses fields > # in MARC editor, 000 contains the leader. >- next if $tag == $biblionumbertagfield; >- if ( $tag eq '000' ) { >+ if ( $tag == $biblionumbertagfield ) { >+ # We do nothing and let $i be incremented >+ } >+ elsif ( $tag eq '000' ) { > # Force a fake leader even if not provided to avoid crashing > # during decoding MARC record containing UTF-8 characters > $record->leader( >@@ -2561,7 +2565,9 @@ sub TransformHtmlToMarc { > # browse subfields for this tag (reason for _code_ match) > while(defined $params[$j] && $params[$j] =~ /_code_/) { > last unless defined $params[$j+1]; >- $j += 2 and next if $tag == $biblionumbertagfield and $cgi->param($params[$j]) eq $biblionumbertagsubfield; >+ $j += 2 and next >+ if $tag == $biblionumbertagfield and >+ $cgi->param($params[$j]) eq $biblionumbertagsubfield; > #if next param ne subfield, then it was probably empty > #try next param by incrementing j > if($params[$j+1]!~/_subfield_/) {$j++; next; } >diff --git a/authorities/authorities.pl b/authorities/authorities.pl >index 2eba66e..ca3b0d3 100755 >--- a/authorities/authorities.pl >+++ b/authorities/authorities.pl >@@ -612,7 +612,7 @@ if ($op eq "add") { > # build indicator hash. > my @ind_tag = $input->param('ind_tag'); > my @indicator = $input->param('indicator'); >- my $record = TransformHtmlToMarc($input); >+ my $record = TransformHtmlToMarc($input, 0); > > my ($duplicateauthid,$duplicateauthvalue); > ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority($record,$authtypecode) if ($op eq "add") && (!$is_a_modif); >diff --git a/authorities/merge.pl b/authorities/merge.pl >index f34e55c..cfc1ca5 100755 >--- a/authorities/merge.pl >+++ b/authorities/merge.pl >@@ -49,7 +49,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > if ($merge) { > > # Creating a new record from the html code >- my $record = TransformHtmlToMarc($input); >+ my $record = TransformHtmlToMarc($input, 0); > my $recordid1 = $input->param('recordid1'); > my $recordid2 = $input->param('recordid2'); > my $typecode = $input->param('frameworkcode'); >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index b6805c9..e34557c 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -834,7 +834,7 @@ if ( $op eq "addbiblio" ) { > ); > # getting html input > my @params = $input->param(); >- $record = TransformHtmlToMarc( $input ); >+ $record = TransformHtmlToMarc( $input, 1 ); > # check for a duplicate > my ( $duplicatebiblionumber, $duplicatetitle ); > if ( !$is_a_modif ) { >@@ -948,7 +948,7 @@ elsif ( $op eq "delete" ) { > } > > if($changed_framework eq "changed"){ >- $record = TransformHtmlToMarc( $input ); >+ $record = TransformHtmlToMarc( $input, 1 ); > } > elsif( $record ne -1 ) { > #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding >diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl >index 490eaa1..a882daa 100755 >--- a/cataloguing/merge.pl >+++ b/cataloguing/merge.pl >@@ -55,7 +55,7 @@ if ($merge) { > my $dbh = C4::Context->dbh; > > # Creating a new record from the html code >- my $record = TransformHtmlToMarc( $input ); >+ my $record = TransformHtmlToMarc( $input, 1 ); > my $ref_biblionumber = $input->param('ref_biblionumber'); > @biblionumbers = grep { $_ != $ref_biblionumber } @biblionumbers; > >-- >2.7.0
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 15572
:
46619
|
46620
|
46621
|
46635
|
46636
|
46637
|
46641
|
46642
|
46643