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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sun Dec 22 10:01:28 2024 UTC