Currently, hook_xmlrpc allows developers to declare 0 or 1 signature, but the introspection spec allows multiple signatures per method.
A simple way of achieving this would be to slightly change hook_xmlrpc() so that when using the second format, the optional signature argument is no longer a (return, param1, ...) array, but an array of such. This would then allow methodSignature to return the multiple signatures as described in the introspection spec, working around issues like #749572: XML-RPC Server returns failure if you send less than the correct amount of arguments even when arguments are optional in an interoperable fashion instead of using our custom way of defining optional parameters.
This is basically how the Python twisted package does it, for instance: http://twistedmatrix.com/documents/10.1.0/web/howto/xmlrpc.html#auto3 they add an array of signature arrays to the package.
Comment | File | Size | Author |
---|---|---|---|
#2 | xmlrpc_897140.patch | 2.25 KB | fgm |
Comments
Comment #1
fgmActually, this is not a feature, but a bug in our current implementation. As specified in the introspection spec "The result is an XML-RPC array, with each element representing one method signature. The array is a list of the signatures of the method. There are no duplicate signatures.".
But what system.methodSignature currently returns is just one such element, and not an array of them. So, even if we do not want to allow hook_xmlrpc implementations to declare multiple possible signatures, we MUST return an array of signatures for interoperability, even if it contains only one element: the spec acknowledges that
anyway.This bug has been there since the "new" XML-RPC implementation in Drupal 4.6.3. The "old" XML-RPC layer was apparently correct in that regard, though, as it would build an array of arrays.
Comment #2
fgmIf we do not want to enact bigger changes, this minimal patch makes us compliant/interoperable with the spec, without changing the hook_xmlrpc definition to allow multiple signatures.
It includes an extra test for the format of methodSignature.
Comment #3
fgmmaking title more accurate
Comment #4
fgm#2: xmlrpc_897140.patch queued for re-testing.
For whomever wants to review this patch, the spec is here: http://xmlrpc-c.sourceforge.net/introspection.html
Comment #5
mlncn CreditAttribution: mlncn commentedI hope no one is relying on the incorrect implementation, but as this is what is returned not accepted there is no other way to correct. RTBC.
Comment #6
dawehnerComment #7
Dries CreditAttribution: Dries commentedCommitted to 7.x and 8.x, even though it is a small API change. It's a bugfix though -- it is important to follow the specification.
Comment #8
bfroehle CreditAttribution: bfroehle commentedUntagging since it's been committed to 7.x