Opened 15 years ago
Closed 14 years ago
#10778 closed defect (bug) (fixed)
PHP Warning in class-IXR.php when $method is array
Reported by: | orensol | Owned by: | josephscott |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | XML-RPC | Keywords: | xmlrpc, class-IXR, warning |
Focuses: | Cc: |
Description
On line 352 in class-IXR.php, there's a call to substr() with $method as the first parameter, which issues the following PHP warning if $method is an array:
PHP Warning: substr() expects parameter 1 to be string, array given
Only later on line 363 there's a call to is_array() on $method.
Suggested fix:
condition the call to substr if !is_array($method).
Attachments (1)
Change History (7)
#1
@
15 years ago
- Cc joseph@… added
- Component changed from General to XML-RPC
- Milestone changed from Unassigned to 2.9
- Owner set to josephscott
#2
@
15 years ago
Include the attached my_xmlrpc_server.php at some point (I do it inside a mu-plugin).
Then call the XMLRPC My.someFunction.
This should generate the PHP Warning.
#3
@
15 years ago
Can you provide steps to reproduce the warning using the core WP code?
As a side note, you can add and alter the XML-RPC methods WP provides by just using the built filter system.
#4
@
15 years ago
There is a problem at line 352 of wp-includes/class-IXR.php when system call:
substr($method, 0, 5)
$method can be an array, as you can see line 363 of wp-includes/class-IXR.php
if(is_array($method))
If $method is an array, the substr function on line 352 display a Warning Error.
If $method is an array, system will display a Warning Error but continue doing well on server side.
If $method is an array, the client will NOT be ok when it analyse the returned xml because there is the Warning displaying on the XML returned, not well formed.
On xmlrpc.php there is that on line 57/58:
// Turn off all warnings and errors. // error_reporting(0);
If you uncomment error_reporting(0), you can't see the bug. Maybe a relation?
$method is an array when you call a method from an object plugin, like that :
In constructor class:
add_action('xmlrpc_methods', array(&$this, 'xmlrpc_methods'));
Then in the class of plugin, the given method array array(&$this, 'xmlrpc_testConnexion') is the problem:
public function xmlrpc_methods($methods) { $methods['pu.testConnexion'] = array(&$this, 'xmlrpc_testConnexion');; return $methods; }
And the function in the class:
public function xmlrpc_testConnexion($args){ return "test"; }
The xml returned is :
<br /><b>Warning</b>: substr() expects parameter 1 to be string, array given in <b>C:\XXX\class-IXR.php</b> on line <b>352</b><br /><methodResponse><params><param><value><string>test</string></value></param></params></methodResponse>"
PHP Version is 5.3.0
Can you outline the exact steps to reproduce the warning so that I can confirm it and work up a patch?