felipe                                   Tue, 24 Nov 2009 11:32:31 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291260

Log:
- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in 
calling function)

Bug: http://bugs.php.net/50282 (Open) xmlrpc_encode_request() changes object 
into array in calling function
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    A   php/php-src/branches/PHP_5_2/ext/xmlrpc/tests/bug50282.phpt
    U   php/php-src/branches/PHP_5_2/ext/xmlrpc/xmlrpc-epi-php.c
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50282.phpt
    U   php/php-src/branches/PHP_5_3/ext/xmlrpc/xmlrpc-epi-php.c
    A   php/php-src/trunk/ext/xmlrpc/tests/bug50282.phpt
    U   php/php-src/trunk/ext/xmlrpc/xmlrpc-epi-php.c

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS	2009-11-24 11:08:16 UTC (rev 291259)
+++ php/php-src/branches/PHP_5_2/NEWS	2009-11-24 11:32:31 UTC (rev 291260)
@@ -8,6 +8,8 @@

 - Fixed error_log() to be binary safe when using message_type 3. (Jani)

+- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in
+  calling function). (Felipe)
 - Fixed bug #50219 (soap call Segmentation fault on a redirected url).
   (Pierrick)
 - Fixed bug #50207 (segmentation fault when concatenating very large strings

Added: php/php-src/branches/PHP_5_2/ext/xmlrpc/tests/bug50282.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/xmlrpc/tests/bug50282.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/xmlrpc/tests/bug50282.phpt	2009-11-24 11:32:31 UTC (rev 291260)
@@ -0,0 +1,43 @@
+--TEST--
+Bug #50282 (xmlrpc_encode_request() changes object into array in calling function)
+--SKIPIF--
+<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
+--FILE--
+<?php
+
+class One { var $x = 10; }
+
+$o = new One();
+var_dump($o);
+var_dump(xmlrpc_encode_request('test', $o));
+var_dump($o);
+
+?>
+--EXPECTF--
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}
+string(279) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>test</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>x</name>
+     <value>
+      <int>10</int>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}


Property changes on: php/php-src/branches/PHP_5_2/ext/xmlrpc/tests/bug50282.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_2/ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:08:16 UTC (rev 291259)
+++ php/php-src/branches/PHP_5_2/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:32:31 UTC (rev 291260)
@@ -499,6 +499,7 @@
 					zval** pIter;
 					char* my_key;
 					HashTable *ht = NULL;
+					zval *val_arr;

 					ht = HASH_OF(val);
 					if (ht && ht->nApplyCount > 1) {
@@ -506,12 +507,16 @@
 						return NULL;
 					}

-					convert_to_array(val);
-					xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val)));
+					MAKE_STD_ZVAL(val_arr);
+					*val_arr = *val;
+					zval_copy_ctor(val_arr);
+					INIT_PZVAL(val_arr);
+					convert_to_array(val_arr);
+					xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val_arr)));

-					zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
-					while(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
-						int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index);
+					zend_hash_internal_pointer_reset(Z_ARRVAL_P(val_arr));
+					while(zend_hash_get_current_data(Z_ARRVAL_P(val_arr), (void**)&pIter) == SUCCESS) {
+						int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index);

 						switch (res) {
 							case HASH_KEY_NON_EXISTANT:
@@ -532,8 +537,9 @@
 								}
 								break;
 						}
-						zend_hash_move_forward(Z_ARRVAL_P(val));
+						zend_hash_move_forward(Z_ARRVAL_P(val_arr));
 					}
+					zval_ptr_dtor(&val_arr);
 				}
 				break;
 			default:

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2009-11-24 11:08:16 UTC (rev 291259)
+++ php/php-src/branches/PHP_5_3/NEWS	2009-11-24 11:32:31 UTC (rev 291260)
@@ -24,6 +24,8 @@
 - Fixed memory leak in extension loading when an error occurs on Windows.
   (Pierre)

+- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in
+  calling function). (Felipe)
 - Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT). (Jani)
 - Fixed bug #50240 (pdo_mysql.default_socket in php.ini shouldn't used
   if it is empty). (foutrelis at gmail dot com, Ilia)

Added: php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50282.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50282.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50282.phpt	2009-11-24 11:32:31 UTC (rev 291260)
@@ -0,0 +1,43 @@
+--TEST--
+Bug #50282 (xmlrpc_encode_request() changes object into array in calling function)
+--SKIPIF--
+<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
+--FILE--
+<?php
+
+class One { var $x = 10; }
+
+$o = new One();
+var_dump($o);
+var_dump(xmlrpc_encode_request('test', $o));
+var_dump($o);
+
+?>
+--EXPECTF--
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}
+string(279) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>test</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>x</name>
+     <value>
+      <int>10</int>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}


Property changes on: php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50282.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:08:16 UTC (rev 291259)
+++ php/php-src/branches/PHP_5_3/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:32:31 UTC (rev 291260)
@@ -556,6 +556,7 @@
 						zval** pIter;
 						char* my_key;
 						HashTable *ht = NULL;
+						zval *val_arr;

 						ht = HASH_OF(val);
 						if (ht && ht->nApplyCount > 1) {
@@ -563,12 +564,17 @@
 							return NULL;
 						}

-						convert_to_array(val);
-						xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val)));
+						MAKE_STD_ZVAL(val_arr);
+						*val_arr = *val;
+						zval_copy_ctor(val_arr);
+						INIT_PZVAL(val_arr);
+						convert_to_array(val_arr);
+
+						xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val_arr)));

-						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
-						while(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
-							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index);
+						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val_arr));
+						while(zend_hash_get_current_data(Z_ARRVAL_P(val_arr), (void**)&pIter) == SUCCESS) {
+							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index);

 							switch (res) {
 								case HASH_KEY_NON_EXISTANT:
@@ -589,8 +595,9 @@
 									}
 									break;
 							}
-							zend_hash_move_forward(Z_ARRVAL_P(val));
-						}
+							zend_hash_move_forward(Z_ARRVAL_P(val_arr));
+						}
+						zval_ptr_dtor(&val_arr);
 					}
 					break;
 				default:

Added: php/php-src/trunk/ext/xmlrpc/tests/bug50282.phpt
===================================================================
--- php/php-src/trunk/ext/xmlrpc/tests/bug50282.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/xmlrpc/tests/bug50282.phpt	2009-11-24 11:32:31 UTC (rev 291260)
@@ -0,0 +1,43 @@
+--TEST--
+Bug #50282 (xmlrpc_encode_request() changes object into array in calling function)
+--SKIPIF--
+<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
+--FILE--
+<?php
+
+class One { var $x = 10; }
+
+$o = new One();
+var_dump($o);
+var_dump(xmlrpc_encode_request('test', $o));
+var_dump($o);
+
+?>
+--EXPECTF--
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}
+string(279) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>test</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>x</name>
+     <value>
+      <int>10</int>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}


Property changes on: php/php-src/trunk/ext/xmlrpc/tests/bug50282.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- php/php-src/trunk/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:08:16 UTC (rev 291259)
+++ php/php-src/trunk/ext/xmlrpc/xmlrpc-epi-php.c	2009-11-24 11:32:31 UTC (rev 291260)
@@ -560,6 +560,7 @@
 						zval** pIter;
 						zstr my_key;
 						HashTable *ht = NULL;
+						zval *val_arr;

 						ht = HASH_OF(val);
 						if (ht && ht->nApplyCount > 1) {
@@ -567,12 +568,16 @@
 							return NULL;
 						}

-						convert_to_array(val);
-						xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val)));
+						MAKE_STD_ZVAL(val_arr);
+						*val_arr = *val;
+						zval_copy_ctor(val_arr);
+						INIT_PZVAL(val_arr);
+						convert_to_array(val_arr);
+						xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val_arr)));

-						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
-						while (zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
-							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index);
+						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val_arr));
+						while (zend_hash_get_current_data(Z_ARRVAL_P(val_arr), (void**)&pIter) == SUCCESS) {
+							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index);

 							switch (res) {
 								case HASH_KEY_NON_EXISTANT:
@@ -592,8 +597,9 @@
 									}
 									break;
 							}
-							zend_hash_move_forward(Z_ARRVAL_P(val));
-						}
+							zend_hash_move_forward(Z_ARRVAL_P(val_arr));
+						}
+						zval_ptr_dtor(&val_arr);
 					}
 					break;
 				default:
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to