Bug #74975 [NEW]: Different serialization for classes
| From: | gmblar+php at gmail dot com | Date: | Sun, 23 Jul 2017 03:22:05 +0000 |
| Subject: | Bug #74975 [NEW]: Different serialization for classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-210216@lists.php.net to get a copy of this message | ||
From: gmblar+php at gmail dot com
Operating system: MacOS 10.13
PHP version: 7.2.0beta1
Package: XMLRPC-EPI related
Bug Type: Bug
Bug description:Different serialization for classes
Description:
------------
xmlrpc_encode and xmlrpc_encode_request works different if the
properties $xmlrpc_type and $scalar are defined before assigning values
to an object.
If the properties $xmlrpc_type and $scalar are defined, xmlrpc_encode*
don't use the values for serialization.
Test script:
---------------
class Foo {
}
class Bar {
public $xmlrpc_type;
public $scalar;
}
$foo = new Foo();
$foo->xmlrpc_type = 'base64';
$foo->scalar = 'foobar';
$bar = new Bar();
$bar->xmlrpc_type = 'base64';
$bar->scalar = 'foobar';
$xml = xmlrpc_encode([
'foo' => $foo,
'bar' => $bar
]);
var_dump($xml);
Expected result:
----------------
<?xml version="1.0" encoding="utf-8"?>
<params>
<param>
<value>
<struct>
<member>
<name>foo</name>
<value>
<base64>Zm9vYmFy </base64>
</value>
</member>
<member>
<name>bar</name>
<value>
<base64>Zm9vYmFy </base64>
</value>
</member>
</struct>
</value>
</param>
</params>
Actual result:
--------------
<?xml version="1.0" encoding="utf-8"?>
<params>
<param>
<value>
<struct>
<member>
<name>foo</name>
<value>
<base64>Zm9vYmFy </base64>
</value>
</member>
<member>
<name>bar</name>
<value>
<struct>
<member>
<name>xmlrpc_type</name>
<value>
<string>base64</string>
</value>
</member>
<member>
<name>scalar</name>
<value>
<string>foobar</string>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</param>
</params>
--
Edit bug report at https://bugs.php.net/bug.php?id=74975&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74975&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74975&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74975&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74975&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74975&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74975&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74975&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74975&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74975&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74975&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74975&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74975&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74975&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74975&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74975&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74975&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74975&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74975&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74975&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74975&r=mysqlcfg