php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61774 Public object variables with numbers as name are not public after unserialize
Submitted: 2012-04-19 14:43 UTC Modified: 2012-04-20 06:15 UTC
From: pandenitz at mail dot ru Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.3.11RC2 OS: Win 7 64x
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: pandenitz at mail dot ru
New email:
PHP Version: OS:

 

 [2012-04-19 14:43 UTC] pandenitz at mail dot ru
Description:
------------
Object variables with numbers as name are not public after unserialize.
So i.e. get_object_vars() doesn't return this vars because they are not public

Test script:
---------------
<?php

$a = new stdClass;
$varname = '1';
$a->$varname = 1;
$a->test = 1;

var_dump($a);
print_r($a);
echo '<hr/>';

$s = serialize($a);
$a2 = unserialize($s);

var_dump($a2);
print_r($a2);
echo '<hr/>';

var_dump(get_object_vars($a2));
print_r(get_object_vars($a2)); 

Expected result:
----------------
Such vars should be public after unserialize.

Actual result:
--------------
Vars are not actually public.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-19 22:38 UTC] nikic@php.net
Can repro on PHP 5.3, but not on 5.4. Everything fine there.
 [2012-04-19 22:51 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2012-04-19 22:51 UTC] nikic@php.net
Actually, I just tried again with a more updated 5.3 build and it works fine there.

The issue was fixed in http://svn.php.net/viewvc?view=revision&revision=317438 which shipped with PHP 5.3.9.

Could you check a PHP 5.3 build >= 5.3.9 and see whether the issue persists?
 [2012-04-20 06:15 UTC] pandenitz at mail dot ru
Yes, I can confirm that it is fixed in recent 5.3.10.
Closing issue.
 [2012-04-20 06:15 UTC] pandenitz at mail dot ru
-Status: Feedback +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 04:01:29 2025 UTC