php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73407 mb_convert_variables() corrupts class definition
Submitted: 2016-10-28 06:45 UTC Modified: -
Votes:19
Avg. Score:4.4 ± 1.1
Reproduced:15 of 16 (93.8%)
Same Version:8 (53.3%)
Same OS:5 (33.3%)
From: alexey dot loskutov at corp dot oft-e dot com Assigned:
Status: Open Package: mbstring related
PHP Version: 5.6.27 OS: ubuntu 16.04 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 - 45 = ?
Subscribe to this entry?

 
 [2016-10-28 06:45 UTC] alexey dot loskutov at corp dot oft-e dot com
Description:
------------
If we apply mb_convert_variables on class which have array properties next created object of this class have been corrupted default value of array properties.

Also if we set property of another class by object of 1st class and apply mb_convert_variables on 2nd class next created object of 1st class have been corrupted values of array properties too.

Test script:
---------------
# example 1
class A {
    public $prop = [1,2,3];
}
class B{
    public $someProp;
}

$a = new A;
$b = new B;
$b->someProp = $a->prop;
mb_convert_variables('UTF-8', 'CP1252', $b);

$a = new A;
print_r($a);

# example 2
class C {
    public $prop = ['string', 'string2'];
}

$c = new C;
mb_convert_variables('UTF-8', 'CP1252', $c);
$c = new C;
print_r($c);


Expected result:
----------------
A Object
(
    [prop] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

)
C Object
(
    [prop] => Array
        (
            [0] => string
            [1] => string2
        )

)


Actual result:
--------------
A Object
(
    [prop] => Array
 *RECURSION*
)
C Object
(
    [prop] => Array
 *RECURSION*
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC