From 14164a8a09f3bf1ccbb59a1a94ea90231cffadd8 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 31 Oct 2011 02:33:29 +0000 Subject: [PATCH] fix fallout from fixing UTF-8 XML-RPC self-service issues, RT#13656 --- FS/FS/ClientAPI_XMLRPC.pm | 32 +++++++++++++++++++- .../FS-SelfService/SelfService/XMLRPC.pm | 34 +++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 5d9196204..1940ca50e 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -30,11 +30,26 @@ L, L use strict; use vars qw($DEBUG $AUTOLOAD); +use XMLRPC::Lite; # for XMLRPC::Data use FS::ClientAPI; $DEBUG = 0; $FS::ClientAPI::DEBUG = $DEBUG; +#false laziness w/FS::SelfService/XMLRPC.pm, same problem as below but worse +our %typefix = ( + 'invoice_pdf' => { 'invoice_pdf' => 'base64', }, + 'legacy_invoice_pdf' => { 'invoice_pdf' => 'base64', }, + 'skin_info' => { 'logo' => 'base64', + 'title_left_image' => 'base64', + 'title_right_image' => 'base64', + 'menu_top_image' => 'base64', + 'menu_body_image' => 'base64', + 'menu_bottom_image' => 'base64', + }, + 'invoice_logo' => { 'logo' => 'base64', }, +); + sub AUTOLOAD { my $call = $AUTOLOAD; $call =~ s/^FS::(SelfService::|ClientAPI_)XMLRPC:://; @@ -44,12 +59,27 @@ sub AUTOLOAD { my $autoload = &ss2clientapi; if (exists($autoload->{$call})) { + shift; #discard package name; + #$call = "FS::SelfService::$call"; #no strict 'refs'; #&{$call}(@_); #FS::ClientAPI->dispatch($autoload->{$call}, @_); - FS::ClientAPI->dispatch($autoload->{$call}, { @_ } ); + + my $return = FS::ClientAPI->dispatch($autoload->{$call}, { @_ } ); + + if ( exists($typefix{$call}) ) { + my $typefix = $typefix{$call}; + foreach my $field ( grep exists($return->{$_}), keys %$typefix ) { + my $type = $typefix->{$field}; + $return->{$field} = XMLRPC::Data->value($return->{$field}) + ->type($type); + } + } + + $return; + }else{ die "No such procedure: $call"; } diff --git a/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm b/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm index 4e0d3e909..59c8756f8 100644 --- a/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm +++ b/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm @@ -26,19 +26,51 @@ L, L,L { 'invoice_pdf' => 'base64', }, + 'legacy_invoice_pdf' => { 'invoice_pdf' => 'base64', }, + 'skin_info' => { 'logo' => 'base64', + 'title_left_image' => 'base64', + 'title_right_image' => 'base64', + 'menu_top_image' => 'base64', + 'menu_body_image' => 'base64', + 'menu_bottom_image' => 'base64', + }, + 'invoice_logo' => { 'logo' => 'base64', }, +); + sub AUTOLOAD { my $call = $AUTOLOAD; $call =~ s/^FS::SelfService::XMLRPC:://; + if (exists($FS::SelfService::autoload{$call})) { + shift; #discard package name; + $call = "FS::SelfService::$call"; + no strict 'refs'; - &{$call}(@_); + + my $return = &{$call}(@_); + + if ( exists($typefix{$call}) ) { + my $typefix = $typefix{$call}; + foreach my $field ( grep exists($return->{$_}), keys %$typefix ) { + my $type = $typefix->{$field}; + $return->{$field} = XMLRPC::Data->value($return->{$field}) + ->type($type); + } + } + + $return; + }else{ die "No such procedure: $call"; } -- 2.11.0