]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/external.pm
meta plugin: also collect [[!meta uuid="..."]]
[git.ikiwiki.info.git] / IkiWiki / Plugin / external.pm
index 300dee7ed5fe89f96eff5d7d3e547c2e210678a3..204442c1e0b731db6d985cef61181e0c7b0fc424 100644 (file)
@@ -68,7 +68,22 @@ sub rpc_call ($$;@) { #{{{
                                        return @{$value->value};
                                }
                                elsif ($value->isa('RPC::XML::struct')) {
-                                       return %{$value->value};
+                                       my %hash=%{$value->value};
+
+                                       # XML-RPC v1 does not allow for
+                                       # nil/null/None/undef values to be
+                                       # transmitted, so until
+                                       # XML::RPC::Parser honours v2
+                                       # (<nil/>), external plugins send
+                                       # a hash with one key "null" pointing
+                                       # to an empty string.
+                                       if (exists $hash{null} &&
+                                           $hash{null} eq "" &&
+                                           int(keys(%hash)) == 1) {
+                                               return undef;
+                                       }
+
+                                       return %hash;
                                }
                                else {
                                        return $value->value;
@@ -92,6 +107,14 @@ sub rpc_call ($$;@) { #{{{
                                error("XML RPC call error, unknown function: $name");
                        }
 
+                       # XML-RPC v1 does not allow for nil/null/None/undef
+                       # values to be transmitted, so until XML::RPC::Parser
+                       # honours v2 (<nil/>), send a hash with one key "null"
+                       # pointing to an empty string.
+                       if (! defined $ret) {
+                               $ret={"null" => ""};
+                       }
+
                        my $string=eval { RPC::XML::response->new($ret)->as_string };
                        if ($@ && ref $ret) {
                                # One common reason for serialisation to
@@ -128,9 +151,10 @@ sub setvar ($$$;@) { #{{{
        my $plugin=shift;
        my $varname="IkiWiki::".shift;
        my $key=shift;
+       my $value=shift;
 
        no strict 'refs';
-       my $ret=$varname->{$key}=@_;
+       my $ret=$varname->{$key}=$value;
        use strict 'refs';
        return $ret;
 } #}}}
@@ -149,20 +173,22 @@ sub setstate ($$$$;@) { #{{{
        my $page=shift;
        my $id=shift;
        my $key=shift;
+       my $value=shift;
 
-       return $IkiWiki::pagestate{$page}{$id}{$key}=@_;
+       return $IkiWiki::pagestate{$page}{$id}{$key}=$value;
 } #}}}
 
 sub getargv ($) { #{{{
        my $plugin=shift;
 
-       return @ARGV;
+       return \@ARGV;
 } #}}}
 
 sub setargv ($@) { #{{{
        my $plugin=shift;
+       my $array=shift;
 
-       @ARGV=@_;
+       @ARGV=@$array;
 } #}}}
 
 sub inject ($@) { #{{{