php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27446 [PATCH] system.multiCall does not work
Submitted: 2004-03-01 07:56 UTC Modified: 2010-01-17 17:20 UTC
Votes:18
Avg. Score:4.4 ± 0.8
Reproduced:14 of 14 (100.0%)
Same Version:9 (64.3%)
Same OS:6 (42.9%)
From: tomy at envox dot hr Assigned:
Status: Closed Package: XMLRPC-EPI related
PHP Version: 5CVS, 6CVS (2008-07-21) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tomy at envox dot hr
New email:
PHP Version: OS:

 

 [2004-03-01 07:56 UTC] tomy at envox dot hr
Description:
------------
When building xmlrpc server, system.multiCall method does not work with my method but works with "built-in" methods such as system.listMethods or system.methodHelp.

I have tested this on latest CVS snapshots both for PHP4 and PHP5, on Suse 8.2.

In following example I have submitted http request sent to server whose code is presented in "Reproduce code".
I do not get nay response and HTTP connection to server is dropped.

Calling "built-in" methods such as system.listMethods or system.methodHelp using system.multiCall works OK.
Calling my method ("contact.select") in a straight fashion (without system.multiCall) works OK here is request and response with headers:

POST /xmlrpc_server.php HTTP/1.0
Content-Type: text/xml
Content-Length: 317

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>contact.select</methodName>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name>SESSIONID</name>
     <value>
      <string>1234567890</string>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodCall>

Response received:

replyLine: HTTP/1.1 200 OK

HEADER : Date: Mon, 01 Mar 2004 12:09:59 GMT
HEADER : Server: Apache/1.3.27 (Linux/SuSE) mod_python/2.7.8 Python/2.2.2 PHP/4.3.5RC4-dev
HEADER : X-Powered-By: PHP/4.3.5RC4-dev
HEADER : Content-Length: 375
HEADER : Connection: close
HEADER : Content-Type: text/xml

<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name>AUTH</name>
     <value>
      <int>1</int>
     </value>
    </member>
    <member>
     <name>SESSIONID</name>
     <value>
      <string>1234567890</string>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodResponse>



Reproduce code:
---------------
<?php
function select_contact($method_name, $params, $app_data)
{
   if (count($params) == 0 || !array_key_exists("SESSIONID", $params[0])) {
      return array("AUTH" => 0);
   } 
   
   return array("AUTH"=>1, "SESSIONID"=>$params[0]["SESSIONID"]);
} 

$xmlrpc_server = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc_server, "contact.select", "select_contact");
$request_xml = $HTTP_RAW_POST_DATA;

$response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, array());
header("Content-Type: text/xml");
header("Content-Length: " . strlen($response));
print $response;
xmlrpc_server_destroy($xmlrpc_server);

?>


Expected result:
----------------
XMLRPC request sent to server:

POST /xmlrpc_server.php HTTP/1.0
Content-Type: text/xml
Content-Length: 837

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>system.multiCall</methodName>
<params>
 <param>
  <value>
   <array>
    <data>
     <value>
      <struct>
       <member>
        <name>methodName</name>
        <value>
         <string>contact.select</string>
        </value>
       </member>
       <member>
        <name>params</name>
        <value>
         <array>
          <data>
           <value>
            <struct>
             <member>
              <name>SESSIONID</name>
              <value>
               <string>1234567890</string>
              </value>
             </member>
            </struct>
           </value>
          </data>
         </array>
        </value>
       </member>
      </struct>
     </value>
    </data>
   </array>
  </value>
 </param>
</params>
</methodCall>

I would expect response like this:

replyLine: HTTP/1.1 200 OK

HEADER : Date: Mon, 01 Mar 2004 12:09:59 GMT
HEADER : Server: Apache/1.3.27 (Linux/SuSE) mod_python/2.7.8 Python/2.2.2 PHP/4.3.5RC4-dev
HEADER : X-Powered-By: PHP/4.3.5RC4-dev
HEADER : Content-Length: 694
HEADER : Connection: close
HEADER : Content-Type: text/xml

<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
 <param>
  <value>
   <array>
    <data>
     <value>
      <array>
       <data>
        <value>
         <struct>
          <member>
           <name>AUTH</name>
           <value>
            <int>1</int>
           </value>
          </member>
          <member>
            <name>SESSIONID</name>
            <value>
            <string>1234567890</string>
           </value>
          </member>
         </struct>
        </value>
       </data>
      </array>
     </value>
    </data>
   </array>
  </value>
 </param>
</params>
</methodResponse>


Actual result:
--------------
XMLRPC request sent to server:

POST /xmlrpc_server.php HTTP/1.0
Content-Type: text/xml
Content-Length: 837

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>system.multiCall</methodName>
<params>
 <param>
  <value>
   <array>
    <data>
     <value>
      <struct>
       <member>
        <name>methodName</name>
        <value>
         <string>contact.select</string>
        </value>
       </member>
       <member>
        <name>params</name>
        <value>
         <array>
          <data>
           <value>
            <struct>
             <member>
              <name>SESSIONID</name>
              <value>
               <string>1234567890</string>
              </value>
             </member>
            </struct>
           </value>
          </data>
         </array>
        </value>
       </member>
      </struct>
     </value>
    </data>
   </array>
  </value>
 </param>
</params>
</methodCall>

After request is sent, HTTP connection is dropped and no response is received.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-15 23:35 UTC] sniper@php.net
It crashes, here's the backtrace with latest CVS checkout:

0x404b9e8c in call_user_function_ex (function_table=0x80b8868, object_pp=0x0, function_name=0x0,
    retval_ptr_ptr=0xbfffc954, param_count=3, params=0x8218104, no_separation=1, symbol_table=0x0)
    at /usr/src/web/php/php4/Zend/zend_execute_API.c:445
445             if (function_name->type==IS_ARRAY) { /* assume array($obj, $name) couple */
(gdb)
(gdb) bt
#0  0x404b9e8c in call_user_function_ex (function_table=0x80b8868, object_pp=0x0, function_name=0x0,
    retval_ptr_ptr=0xbfffc954, param_count=3, params=0x8218104, no_separation=1, symbol_table=0x0)
    at /usr/src/web/php/php4/Zend/zend_execute_API.c:445
#1  0x404b9d7e in call_user_function (function_table=0x80b8868, object_pp=0x0, function_name=0x0, retval_ptr=0x8219d0c,
    param_count=3, params=0xbfffc990) at /usr/src/web/php/php4/Zend/zend_execute_API.c:409
#2  0x404774b0 in php_xmlrpc_callback (server=0x821b008, xRequest=0x8219fa8, data=0xbfffcae0)
    at /usr/src/web/php/php4/ext/xmlrpc/xmlrpc-epi-php.c:882
#3  0x404800fc in XMLRPC_ServerCallMethod (server=0x821b008, request=0x8219fa8, userData=0xbfffcae0)
    at /usr/src/web/php/php4/ext/xmlrpc/libxmlrpc/xmlrpc.c:2522
#4  0x4047b147 in xsm_system_multicall_cb (server=0x821b008, input=0x8219f48, userData=0xbfffcae0)
    at /usr/src/web/php/php4/ext/xmlrpc/libxmlrpc/system_methods.c:337
#5  0x404800fc in XMLRPC_ServerCallMethod (server=0x821b008, request=0x8219f48, userData=0xbfffcae0)
    at /usr/src/web/php/php4/ext/xmlrpc/libxmlrpc/xmlrpc.c:2522
#6  0x40477b5d in zif_xmlrpc_server_call_method (ht=3, return_value=0x8219c0c, this_ptr=0x0, return_value_used=1)
    at /usr/src/web/php/php4/ext/xmlrpc/xmlrpc-epi-php.c:1103
#7  0x404d59a8 in execute (op_array=0x8214f1c) at /usr/src/web/php/php4/Zend/zend_execute.c:1621

 [2008-05-02 13:52 UTC] kawai at apache dot org
I also hit this bug in my own server. I analyzed the bug, and created a patch for this:


--- php-5.2.6/ext/xmlrpc/xmlrpc-epi-php.c	Mon Dec 31 16:20:14 2007
+++ xmlrpc-epi-php.c	Fri May  2 22:41:30 2008
@@ -859,6 +859,20 @@
    zval* callback_params[3];
    TSRMLS_FETCH();
    
+	const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
+	zval **php_function;
+	if (!methodname) { methodname = ""; }
+	Z_STRVAL_P(pData->xmlrpc_method) = estrdup(methodname);
+	Z_STRLEN_P(pData->xmlrpc_method) = strlen(methodname);
+	Z_TYPE_P(pData->xmlrpc_method) = IS_STRING;
+	pData->php_executed = 0;
+	if(zend_hash_find(Z_ARRVAL_P(pData->server->method_map),
+                      Z_STRVAL_P(pData->xmlrpc_method), 
+                      Z_STRLEN_P(pData->xmlrpc_method) + 1, 
+                      (void**)&php_function) == SUCCESS) {
+		pData->php_function = *php_function;
+	}
+   
    /* convert xmlrpc to native php types */
    xmlrpc_params = XMLRPC_to_PHP(XMLRPC_RequestGetData(xRequest));
 
@@ -876,7 +890,7 @@
 
    zval_ptr_dtor(&xmlrpc_params);
 
-   return NULL;
+   return PHP_to_XMLRPC(pData->return_data TSRMLS_CC);
 }
 
 /* called by the C server when it first receives an introspection request.  We pass this on to
@@ -1017,7 +1031,6 @@
    Parses XML requests and call methods */
 PHP_FUNCTION(xmlrpc_server_call_method)
 {
-	xmlrpc_callback_data data = {0};
 	XMLRPC_REQUEST xRequest;
 	STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
 	xmlrpc_server_data* server;
@@ -1048,8 +1061,8 @@
 
 		if(xRequest) {
 			const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
-			zval **php_function;
-			XMLRPC_VALUE xAnswer = NULL;
+			
+			xmlrpc_callback_data data = {0};
 			MAKE_STD_ZVAL(data.xmlrpc_method); /* init. very important.  spent a frustrating day finding this out. */
 			MAKE_STD_ZVAL(data.return_data);
 			Z_TYPE_P(data.return_data) = IS_NULL;  /* in case value is never init'd, we don't dtor to think it is a string or something */
@@ -1060,26 +1073,15 @@
 			}
             
 			/* setup some data to pass to the callback function */
-			Z_STRVAL_P(data.xmlrpc_method) = estrdup(methodname);
-			Z_STRLEN_P(data.xmlrpc_method) = strlen(methodname);
-			Z_TYPE_P(data.xmlrpc_method) = IS_STRING;
 			data.caller_params = *caller_params;
 			data.php_executed = 0;
 			data.server = server;
 
-			/* check if the called method has been previous registered */
-			if(zend_hash_find(Z_ARRVAL_P(server->method_map),
-                              Z_STRVAL_P(data.xmlrpc_method), 
-                              Z_STRLEN_P(data.xmlrpc_method) + 1, 
-                              (void**)&php_function) == SUCCESS) {
-
-				data.php_function = *php_function;
-			}
-
 			/* We could just call the php method directly ourselves at this point, but we do this 
 			 * with a C callback in case the xmlrpc library ever implements some cool usage stats,
 			 * or somesuch.
 			 */
+			XMLRPC_VALUE xAnswer = NULL;
 			xAnswer = XMLRPC_ServerCallMethod(server->server_ptr, xRequest, &data);
 			if(xAnswer && out.b_php_out) {
 				zval_dtor(data.return_data);
@@ -1086,7 +1088,9 @@
 				FREE_ZVAL(data.return_data);
 				data.return_data = XMLRPC_to_PHP(xAnswer);
 			} else if(data.php_executed && !out.b_php_out) {
-				xAnswer = PHP_to_XMLRPC(data.return_data TSRMLS_CC);
+				if(!xAnswer){
+					xAnswer = PHP_to_XMLRPC(data.return_data TSRMLS_CC);
+				}
 			}
 
 			/* should we return data as xml? */
 [2008-05-28 05:53 UTC] kawai at apache dot org
Now, you can download patched version of xmlrpc extension from:
http://mp.i-revo.jp/user.php/kcvcrlkq/entry/309.html

I hope this patch to be applied in the next PHP release.
 [2009-02-09 14:37 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-02-17 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-02-27 07:25 UTC] kawai at apache dot org
I downloaded php5.2-200902270530, and tested. This issue was not 
fixed.
 [2009-02-27 07:27 UTC] kawai at apache dot org
Please reopen this ticket.
 [2010-01-17 17:20 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC