Item14802: JsonRpcContrib Request does not support multi_param
Priority: Urgent
Current State: Closed
Released In: 2.2.0
Target Release: minor
(Using 2.1.3 with the released
JsonRpcContrib and
MultiSaveContrib from Extensions)
If you don't have a
Foswiki::Request::JSON
in Foswiki::Contrib::JsonRpcContrib::Server then the fallback is to construct a new
Foswiki::Contrib::JsonRpcContrib::Request
. However this does not support
multi_param
which causes failures down the line e.g. in
MultiSaveContrib
.
Add the following to
Foswiki::Contrib::JsonRpcContrib::Request
sub multi_param {
my @list_of_params = param(@_);
return @list_of_params;
}
--
CrawfordCurrie - 17 Dec 2018
Can you try the full fix below, please:
diff --git a/JsonRpcContrib/lib/Foswiki/Request/JSON.pm b/JsonRpcContrib/lib/Foswiki/Request/JSON.pm
index 4d8607956..2a32b60e9 100644
--- a/JsonRpcContrib/lib/Foswiki/Request/JSON.pm
+++ b/JsonRpcContrib/lib/Foswiki/Request/JSON.pm
@@ -118,6 +118,12 @@ jsonparam method for read/write access to the JSON dtaa.
sub param {
my ( $this, @p ) = @_;
+ unless (scalar @p) {
+ my @params = $this->SUPER::param();
+ push @params, 'POSTDATA';
+ return @params;
+ }
+
return $this->SUPER::param() unless scalar @p;
my ( $key, @value ) = rearrange( [ 'NAME', [qw(VALUE VALUES)] ], @p );
@@ -136,6 +142,10 @@ sub param {
}
+sub multi_param {
+ return param(@_);
+}
+
=begin TML
---++ ObjectMethod method() ->$restMethod
@@ -256,6 +266,7 @@ sub initFromString {
}
$this->{_jsondata}{params} ||= {};
+ $this->{_jsondata}{params}{POSTDATA} = $data;
return $this->{_jsondata};
}
--
Main.MichaelDaum - 17 Dec 2018 - 11:21
I don't have a
JsonRpcContrib/lib/Foswiki/Request/JSON.pm
in this install. Using
JsonRpcContrib from Extensions, is it only in git?
--
Main.CrawfordCurrie - 17 Dec 2018 - 11:29
In any case your patch is correct. The only other issue is that POSTDATA must not occur in any %QUERYSTRING or so...
--
MichaelDaum - 17 Dec 2018
It was correct, but incomplete. I had to hack
param
as well, to add:
return keys( %{$this->{data}{params}} ) unless $key;
This addresses my immediate need (it gets
MultiSaveContrib working), but I'm not sure if it meets the full spec of CGI::param even then. I guess this will all go away when
JsonRpcContrib is re-released.
--
Main.CrawfordCurrie - 17 Dec 2018 - 11:42
I will revert the json-rpc changes on the master branch so both release and master use the same implementation in
JsonRpcContrib. See
Item14899
--
MichaelDaum - 28 Sep 2020