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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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 Apr 27 00:01:30 2024 UTC