From 631c7008f9f06146c66d5bef0e84d245eff12498 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 30 Apr 2009 12:25:27 -0500 Subject: [PATCH] Syndetics: handle variations in reviews XML output For some reason different Syndetics users get slightly different results when requesting an XML-formatted review, so it's necessary to handle both observed variations: Here's one variation: ... This is a review And another: ... This is a review This patch fixes a bug where some users the source of a review but not the review itself. Signed-off-by: Galen Charlton --- C4/External/Syndetics.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/C4/External/Syndetics.pm b/C4/External/Syndetics.pm index 35957dfde4..5275cc90c0 100644 --- a/C4/External/Syndetics.pm +++ b/C4/External/Syndetics.pm @@ -231,7 +231,16 @@ sub get_syndetics_reviews { for my $subfield_a (@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}}) { my @content; # this is absurd, but sometimes this data serializes differently - if(ref($subfield_a->{a}->{content}) eq 'ARRAY') { + if (exists $subfield_a->{content}) { + if (ref($subfield_a->{content} eq 'ARRAY')) { + for my $content (@{$subfield_a->{content}}) { + push @content, {content => $content}; + } + } else { + push @content, {content => $subfield_a->{content}}; + } + } + elsif(ref($subfield_a->{a}->{content}) eq 'ARRAY') { for my $content (@{$subfield_a->{a}->{content}}) { push @content, {content => $content}; } -- 2.39.2