Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2b8066

Browse files
blarnikic
authored andcommitted
Bug #74975: Different serialization for classes
1 parent 9ca1b2a commit c2b8066

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ PHP NEWS
4646
. Fixed bug #74669 (Unserialize ArrayIterator broken). (Andrew Nester)
4747
. Fixed bug #75015 (Crash in recursive iterator destructors). (Julien)
4848

49+
- XMLRPC:
50+
. Fixed bug #74975 (Incorrect xmlrpc serialization for classes with declared
51+
properties). (blar)
52+
4953
03 Aug 2017 PHP 7.0.22
5054

5155
- Core:

ext/xmlrpc/tests/bug74975.phpt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--TEST--
2+
Bug #74975 Different serialization for classes
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("xmlrpc")) print "skip";
6+
?>
7+
--FILE--
8+
<?php
9+
10+
class Foo {
11+
12+
}
13+
14+
class Bar {
15+
16+
public $xmlrpc_type;
17+
public $scalar;
18+
19+
}
20+
21+
$foo = new Foo();
22+
$foo->xmlrpc_type = 'base64';
23+
$foo->scalar = 'foobar';
24+
25+
$bar = new Bar();
26+
$bar->xmlrpc_type = 'base64';
27+
$bar->scalar = 'foobar';
28+
29+
echo xmlrpc_encode([
30+
'foo' => $foo,
31+
'bar' => $bar
32+
]);
33+
34+
?>
35+
--EXPECTF--
36+
<?xml version="1.0" encoding="utf-8"?>
37+
<params>
38+
<param>
39+
<value>
40+
<struct>
41+
<member>
42+
<name>foo</name>
43+
<value>
44+
<base64>Zm9vYmFy&#10;</base64>
45+
</value>
46+
</member>
47+
<member>
48+
<name>bar</name>
49+
<value>
50+
<base64>Zm9vYmFy&#10;</base64>
51+
</value>
52+
</member>
53+
</struct>
54+
</value>
55+
</param>
56+
</params>

ext/xmlrpc/xmlrpc-epi-php.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval* newvalue) /* {{{ */
13541354
zval* attr;
13551355
type = xmlrpc_vector;
13561356

1357-
if ((attr = zend_hash_str_find(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1)) != NULL) {
1357+
if ((attr = zend_hash_str_find_ind(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1)) != NULL) {
13581358
if (Z_TYPE_P(attr) == IS_STRING) {
13591359
type = xmlrpc_str_as_type(Z_STRVAL_P(attr));
13601360
}
@@ -1368,7 +1368,7 @@ XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval* newvalue) /* {{{ */
13681368
zval* val;
13691369

13701370
if ((type == xmlrpc_base64 && Z_TYPE_P(value) == IS_OBJECT) || type == xmlrpc_datetime) {
1371-
if ((val = zend_hash_str_find(Z_OBJPROP_P(value), OBJECT_VALUE_ATTR, sizeof(OBJECT_VALUE_ATTR) - 1)) != NULL) {
1371+
if ((val = zend_hash_str_find_ind(Z_OBJPROP_P(value), OBJECT_VALUE_ATTR, sizeof(OBJECT_VALUE_ATTR) - 1)) != NULL) {
13721372
ZVAL_COPY_VALUE(newvalue, val);
13731373
}
13741374
} else {

0 commit comments

Comments
 (0)