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:18
Avg. Score:4.3 ± 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:
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alexey dot loskutov at corp dot oft-e dot com
New email:
PHP Version: OS:

 

 [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: Tue Aug 29 15:01:52 2017 UTC