Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sympa_soap_client.pl fails if SOAP call returns hash result. #1415

Merged
merged 3 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 37 additions & 20 deletions src/bin/sympa_soap_client.pl.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!--PERL--
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$

# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2022 The Sympa Community. See the
# AUTHORS.md file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -31,8 +33,6 @@ use HTTP::Cookies;
#use SOAP::Lite +trace;
use SOAP::Lite;

use Sympa::Tools::Data;

my ($reponse, @ret, $val, %fault);

my $usage =
Expand Down Expand Up @@ -303,25 +303,42 @@ sub play_soap {
sub print_result {
my $r = shift;

# If we get a fault
if (defined $r && $r->fault) {
print "Soap error :\n";
my %fault = %{$r->fault};
foreach $val (keys %fault) {
print "$val = $fault{$val}\n";
}
if ($r->fault) {
print "SOAP error :\n";
_dump_var($r->fault);
} else {
if (ref($r->result) =~ /^ARRAY/) {
#printf "R: $r->result\n";
@ret = @{$r->result};
} elsif (ref $r->result) {
print "Pb " . ($r->result) . "\n";
return undef;
} else {
@ret = $r->result;
}
Sympa::Tools::Data::dump_var(\@ret, 0, \*STDOUT);
_dump_var($r->result);
}

return 1;
}

# Dump a variable's content
# Old name: Sympa::Tools::Data::dump_var().
sub _dump_var {
my $var = shift;
my $level = shift || 0;

if (ref $var eq 'ARRAY') {
foreach my $index (0 .. $#{$var}) {
printf "%s%d\n", "\t" x $level, $index;
_dump_var($var->[$index], $level + 1);
}
} elsif (
grep {
ref $var eq $_
} qw(HASH Sympa::Scenario Sympa::List CGI::Fast)
) {
foreach my $key (sort keys %{$var}) {
printf "%s_%s_\n", "\t" x $level, $key;
_dump_var($var->{$key}, $level + 1);
}
} elsif (ref $var) {
printf "%s'%s'\n", "\t" x $level, ref $var;
} elsif (defined $var) {
printf "%s'%s'\n", "\t" x $level, $var;
} else {
printf "%sUNDEF\n", "\t" x $level;
}
}

9 changes: 2 additions & 7 deletions src/lib/Sympa/Scenario.pm
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$

# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019, 2020, 2021 The Sympa Community. See the
# Copyright 2017, 2018, 2019, 2020, 2021, 2022 The Sympa Community. See the
# AUTHORS.md file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
Expand Down Expand Up @@ -1528,11 +1527,7 @@ sub do_verify_custom {
}

# NEVER USED.
sub dump_all_scenarios {
open my $ofh, '>', '/tmp/all_scenarios';
Sympa::Tools::Data::dump_var(\%all_scenarios, 0, $ofh);
close $ofh;
}
#sub dump_all_scenarios;

sub get_current_title {
my $self = shift;
Expand Down
33 changes: 2 additions & 31 deletions src/lib/Sympa/Tools/Data.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$

# Sympa - SYsteme de Multi-Postage Automatique
#
Expand Down Expand Up @@ -64,36 +63,8 @@ sub recursive_transformation {
return;
}

sub dump_var {
my ($var, $level, $fd) = @_;

return undef unless ($fd);

if (ref($var)) {
if (ref($var) eq 'ARRAY') {
foreach my $index (0 .. $#{$var}) {
print $fd "\t" x $level . $index . "\n";
dump_var($var->[$index], $level + 1, $fd);
}
} elsif (ref($var) eq 'HASH'
|| ref($var) eq 'Sympa::Scenario'
|| ref($var) eq 'Sympa::List'
|| ref($var) eq 'CGI::Fast') {
foreach my $key (sort keys %{$var}) {
print $fd "\t" x $level . '_' . $key . '_' . "\n";
dump_var($var->{$key}, $level + 1, $fd);
}
} else {
printf $fd "\t" x $level . "'%s'" . "\n", ref($var);
}
} else {
if (defined $var) {
print $fd "\t" x $level . "'$var'" . "\n";
} else {
print $fd "\t" x $level . "UNDEF\n";
}
}
}
# Moved to: dumpa_var() in sympa_soap_client.pl.
#sub dump_var;

sub dump_html_var {
my ($var) = shift;
Expand Down
25 changes: 4 additions & 21 deletions src/lib/Sympa/WWW/SharedDocument.pm
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$

# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file at the
# top-level directory of this distribution and at
# Copyright 2017, 2018, 2022 The Sympa Community. See the
# AUTHORS.md file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -37,7 +36,6 @@ use Sympa;
use Conf;
use Sympa::Language;
use Sympa::Scenario;
use Sympa::Tools::Data;
use Sympa::Tools::File;
use Sympa::Tools::Text;

Expand Down Expand Up @@ -503,25 +501,10 @@ sub _by_order {
}

# OBSOLETED. Never used.
sub dump {
my $self = shift;
my $fd = shift;

Sympa::Tools::Data::dump_var($self, 0, $fd);
}
#sub dump;

# OBSOLETED. No longer used.
sub dup {
my $self = shift;

my $copy = {};

foreach my $k (keys %$self) {
$copy->{$k} = $self->{$k};
}

return $copy;
}
#sub dup;

sub count_moderated_descendants {
my $self = shift;
Expand Down