[Koha-patches] [PATCH] Syndetics: handle variations in reviews XML output
Galen Charlton
galen.charlton at liblime.com
Thu Apr 30 19:25:27 CEST 2009
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:
...
<Notes>
<Fld520 I1="BLANK" I2="BLANK">
<a>This is a review
And another:
...
<Notes>
<Fld520 I1="BLANK" I2="BLANK">
This is a review
This patch fixes a bug where some users the
source of a review but not the review itself.
---
C4/External/Syndetics.pm | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/C4/External/Syndetics.pm b/C4/External/Syndetics.pm
index 35957df..5275cc9 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};
}
--
1.5.6.5
More information about the Koha-patches
mailing list