php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26762 unserialize() produces lowercase classnames
Submitted: 2004-01-01 18:04 UTC Modified: 2004-01-02 06:44 UTC
From: mail at alexanderklein dot de Assigned: helly (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.0.0RC1-dev OS: *
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: mail at alexanderklein dot de
New email:
PHP Version: OS:

 

 [2004-01-01 18:04 UTC] mail at alexanderklein dot de
Description:
------------
I use the __autoload($sClass) feature, and the $sClass 
names are always transmitted as is. With upper and
lower characters.

But when i cache a class with serialize and try
to unserialize, the $sClass names are only lowercase.

System 1
    System 	Windows NT 5.1
    Build Date 	Jan 1 2004 16:06:44
    Server API 	CGI/FastCGI
    PHP API 	20031224
    PHP Extension 	20020429
    Zend Extension 	90021012
    
System 2
    System 	Linux * 2.4.18 #1 SMP i686
    Build Date 	Dec 23 2003 04:48:50
    Server API 	Apache
    Virtual Directory Support 	disabled
    PHP API 	20031103
    PHP Extension 	20020429
    Zend Extension 	90021012



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-01 18:24 UTC] mail at alexanderklein dot de
A short sample script

STEP One:

function __autoload($sClass) {
    echo $sClass."<br>";
}

ini_set(
    'unserialize_callback_func',
    '__autoload'
);

class myTestWithUpper {
    public $test;
    protected function __sleep() {
        return array('test');
    }
}

file_put_contents(
    "./test.dat",
    serialize(
        new myTestWithUpper()
    )
);

STEP Two:

unserialize(
    file_get_contents ("./test.dat")
);
 [2004-01-01 19:42 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

In php class names are not case sensitive and are stored in 
lowercase form internally. 
 [2004-01-01 20:21 UTC] mail at alexanderklein dot de
Ok, you say

> In php class names are not case sensitive and are 
> stored in lowercase form internally. 

but why does the __autoload() function not convert to 
lowercase if i make an instance like "new myTestWithUpper"?

this is a _little_ bit confusing :-(
 [2004-01-01 21:25 UTC] helly@php.net
Behavior is correct as you can see below:

marcus@zaphod /usr/src/php5 $ php -r 'class FOO{}$o=new FOO;var_dump(serialize($o));'
string(14) "O:3:"FOO":0:{}"

marcus@zaphod /usr/src/php5 $ php -r '$o=unserialize("O:3:\"FOO\":0:{}");var_dump($o);'
object(__PHP_Incomplete_Class)#1 (1) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(3) "foo"
}

marcus@zaphod /usr/src/php5 $ php -r 'class FOO{}$o=unserialize("O:3:\"FOO\":0:{}");var_dump($o);'
object(FOO)#1 (0) {
}
 [2004-01-01 22:19 UTC] helly@php.net
Actually unserialized lowercases the classname. But we store the lowercased classname only in the hashtable while we preserver the casing for its real name.
 [2004-01-01 22:24 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC