Bug #73407 [Opn->Csd]: mb_convert_variables() corrupts class definition
| From: | nikic@php.net | Date: | Wed, 08 Jan 2020 15:52:47 +0000 |
| Subject: | Bug #73407 [Opn->Csd]: mb_convert_variables() corrupts class definition | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224782@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73407&edit=1
ID: 73407
Updated by: nikic@php.net
Reported by: alexey dot loskutov at corp dot oft-e dot com
Summary: mb_convert_variables() corrupts class definition
-Status: Open
+Status: Closed
Type: Bug
Package: mbstring related
Operating System: ubuntu 16.04 x64
PHP Version: 5.6.27
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This has been fixed in 7.3 apparently: https://3v4l.org/d8fth
Previous Comments:
------------------------------------------------------------------------
[2016-10-28 06:45:47] 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*
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73407&edit=1