When a method is described to hook_xmlrpc without a signature (i.e. either in the simple format or in the complex format with only two parameters), if system.methodSignature is invoked on it, we return a -32601 server error, overloading the standard meaning of error -32601 ("server error. requested method not found" as per http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php) with a message saying the signature was not found.

This appears to have been inspired by the behaviour of the Incution XML-RPC library, but does not match the recommended behaviour of the XML-RPC introspection spec, which says The system.methodSignature result may indicate that the introspection machinery simply does not know what signatures the method has. We call this the "I don't know" result. The "I don't know" result consists of an XML-RPC string with value undef.. In short, asking for the signature of a method without one should not cause an error, but return this "undef" result, or actually anything not a XML-RPC array. As per the spec again: Alternatively, the result can be anything at all that is not an XML-RPC array. The string undef is preferred.

Issue fork xmlrpc-897130

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Daniel Norton’s picture

greggles’s picture

Project: Drupal core » xmlrpc
Version: 8.0.x-dev »
Component: xml-rpc system » Code
Issue summary: View changes

After #1285726-48: Remove XML-RPC moving this to the contributed module home for xmlrpc issues.

megachriz’s picture

Version: » 8.x-1.x-dev
Category: Feature request » Bug report
Status: Active » Needs review
StatusFileSize
new3.05 KB
new6.01 KB

I've worked on this and used #897142: XML-RPC introspection protocol breaks for servers that don’t provide signatures as inspiration.

I've fixed that when calling "system.methodSignature" for a method that has no signature, the string "undef" gets returned and that there is no XML-RPC error.

Warnings logged

Previously, if a XML-RPC method was defined in the complex format, but without a signature defined, you would get the following warnings logged:

Undefined array key 2 in xmlrpc_server()
Undefined array key 3 in xmlrpc_server()

With the change from the patch signature and help have become optional in the complex format. But method name and callback remain required. Therefore I added that a warning must be logged if the XML-RPC method is not correctly defined. When it is missing the method name or callback, it now results into the following logged message with a suggestion of how to fix it:

Wrongly defined XML-RPC method detected. Check implementations of hook_xmlrpc() and hook_xmlrpc_alter() to see which one is wrong.

Signaure is not an array

When a signature is defined, but it is not an array, there is still a XML-RPC error. This time the error message is as follows, with the word 'correctly' being added:

'Server error. Requested method @methodname signature not correctly specified.'

Instead of it being a -32601 error, it is now a -32602 error. On https://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php it is said that that code means "-32602 ---> server error. invalid method parameters". One of the parameters is invalid if the signature is not defined as an array, so it looks me that that error code fits here.

Static class callbacks

I also fixed that static class callbacks can be used for a XML-RPC method:

'test.classCallback' => ['XmlRpcTestClass', 'foo'],

Ideally, this should be fixed in a separate issue, but I wanted to ensure that for the above definition - for which a signature is also not defined - calling the "system.methodSignature" method for it would result into the same.

The test only patch should fail tests. Let's see if the other patch passes tests.

The last submitted patch, 3: xmlrpc-897130-tests-only.patch, failed testing. View results

  • MegaChriz committed be0ded1a on 8.x-1.x
    Issue #897130 by MegaChriz: Fixed system.methodSignature should return "...
megachriz’s picture

Title: system.methodSignature should return "undef" instead of error -32601 » system.methodSignature should return "undef" instead of error -32601
Status: Needs review » Fixed

Merged the code!

fgm’s picture

Thanks for your work on this old issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.