Bugzilla – Attachment 3651 Details for
Bug 5914
BuildUnimarcHierarchies can go into an infinite loop in certain conditions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Replacement patch
0001-Bug-5914-BuildUnimarchierarchies-can-go-into-an-infi.patch (text/plain), 4.57 KB, created by
Stéphane Delaune
on 2011-04-05 08:47:58 UTC
(
hide
)
Description:
Replacement patch
Filename:
MIME Type:
Creator:
Stéphane Delaune
Created:
2011-04-05 08:47:58 UTC
Size:
4.57 KB
patch
obsolete
>From 03a2b4f30b6bd05032b95e550f684c26b699c126 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Tue, 22 Mar 2011 11:34:27 +1300 >Subject: [PATCH] Bug 5914 : BuildUnimarchierarchies can go into an infinite loop Squashed commit of the following: >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >commit 58e18dfa4109fcdde3c71675ff07ed6aae86b258 >Author: Henri-Damien LAURENT <henridamien.laurent@biblibre.com> >Date: Tue May 18 16:54:49 2010 +0200 > > Bug 5914 : followup BuildUnimarchierarchies fixing infinite loop > >commit bbbcb7fcb0ff36eb8a072d9b0442996e71ebb247 >Author: Henri-Damien LAURENT <henridamien.laurent@biblibre.com> >Date: Tue May 18 13:11:44 2010 +0200 > > Bug 5914 : BuildUnimarcHierarchies : Fixing infinite loop > > When referenced authority in 5XX$3 would be the same as the current authid, the script would get into infinite loop > > Conflicts solved: C4/AuthoritiesMarc.pm > >commit 3581021997bc8965af807738c47d5fd27f2fd97f >Author: Henri-Damien LAURENT <henridamien.laurent@biblibre.com> >Date: Wed Apr 7 15:15:59 2010 +0200 > > Bug 5914 : BuildUnimarcHierarchies : Fixing infinite loop > > When referenced authority in 5XX$3 would be the same as the current authid, the script would get into infinite loop > >Signed-off-by: Stéphane Delaune <stephane.delaune@biblibre.com> >--- > C4/AuthoritiesMarc.pm | 66 +++++++++++++++++++++++++----------------------- > 1 files changed, 34 insertions(+), 32 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 0122ca8..d06ffc4 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1125,33 +1125,34 @@ sub BuildUnimarcHierarchies{ > my $data = GetHeaderAuthority($authid); > if ($data->{'authtrees'} and not $force){ > return $data->{'authtrees'}; >- } elsif ($data->{'authtrees'}){ >- $hierarchies=$data->{'authtrees'}; >+# } elsif ($data->{'authtrees'}){ >+# $hierarchies=$data->{'authtrees'}; > } else { > my $record = GetAuthority($authid); > my $found; >- if ($record){ >- foreach my $field ($record->field('550')){ >- if ($field->subfield('5') && $field->subfield('5') eq 'g'){ >- my $parentrecord = GetAuthority($field->subfield('3')); >- my $localresult=$hierarchies; >- my $trees; >- $trees = BuildUnimarcHierarchies($field->subfield('3')); >- my @trees; >- if ($trees=~/;/){ >- @trees = split(/;/,$trees); >- } else { >- push @trees, $trees; >- } >- foreach (@trees){ >- $_.= ",$authid"; >- } >- @globalresult = (@globalresult,@trees); >- $found=1; >- } >- $hierarchies=join(";",@globalresult); >- } >- } >+ return unless $record; >+ foreach my $field ($record->field('5..')){ >+ if ($field->subfield('5') && $field->subfield('5') eq 'g'){ >+ my $subfauthid=_get_authid_subfield($field); >+ next if ($subfauthid eq $authid); >+ my $parentrecord = GetAuthority($subfauthid); >+ my $localresult=$hierarchies; >+ my $trees; >+ $trees = BuildUnimarcHierarchies($subfauthid); >+ my @trees; >+ if ($trees=~/;/){ >+ @trees = split(/;/,$trees); >+ } else { >+ push @trees, $trees; >+ } >+ foreach (@trees){ >+ $_.= ",$authid"; >+ } >+ @globalresult = (@globalresult,@trees); >+ $found=1; >+ } >+ $hierarchies=join(";",@globalresult); >+ } > #Unless there is no ancestor, I am alone. > $hierarchies="$authid" unless ($hierarchies); > } >@@ -1188,15 +1189,16 @@ sub BuildUnimarcHierarchy{ > my $parents=""; my $children=""; > my (@loopparents,@loopchildren); > foreach my $field ($record->field('5..')){ >- my $subfauthid=_get_authid_subfield($field); >- if ($field->subfield('5') && $field->subfield('a')){ >- if ($field->subfield('5') eq 'h'){ >- push @loopchildren, { "childauthid"=>$subfauthid,"childvalue"=>$field->subfield('a')}; >- }elsif ($field->subfield('5') eq 'g'){ >- push @loopparents, { "parentauthid"=>$subfauthid,"parentvalue"=>$field->subfield('a')}; >- } >+ my $subfauthid=_get_authid_subfield($field); >+ if ($subfauthid && $field->subfield('5') && $field->subfield('a')){ >+ if ($field->subfield('5') eq 'h'){ >+ push @loopchildren, { "childauthid"=>$field->subfield('3'),"childvalue"=>$field->subfield('a')}; >+ } >+ elsif ($field->subfield('5') eq 'g'){ >+ push @loopparents, { "parentauthid"=>$field->subfield('3'),"parentvalue"=>$field->subfield('a')}; >+ } > # brothers could get in there with an else >- } >+ } > } > $cell{"ifparents"}=1 if (scalar(@loopparents)>0); > $cell{"ifchildren"}=1 if (scalar(@loopchildren)>0); >-- >1.7.0.4 >
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 5914
:
3375
|
3389
|
3637
| 3651