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: 2020-01-08 15:52 UTC
Votes:28
Avg. Score:4.2 ± 1.1
Reproduced:22 of 23 (95.7%)
Same Version:11 (50.0%)
Same OS:7 (31.8%)
From: alexey dot loskutov at corp dot oft-e dot com Assigned: nikic (profile)
Status: Closed Package: mbstring related
PHP Version: 5.6.27 OS: ubuntu 16.04 x64
Private report: No CVE-ID: None
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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-08 15:52 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-01-08 15:52 UTC] nikic@php.net
This has been fixed in 7.3 apparently: https://3v4l.org/d8fth
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 03:01:29 2024 UTC