|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26724 get_class() and __CLASS__ causing crashes and erratic behaviour
Submitted: 2003-12-26 22:34 UTC Modified: 2003-12-29 22:48 UTC
From: thought at phenomind dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5CVS-2003-12-26 (dev) OS: Windows XP
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.
Bug Type:
From: thought at phenomind dot com
New email:
PHP Version: OS:


 [2003-12-26 22:34 UTC] thought at phenomind dot com
Apologise for not being able to describe this better or give example code. 

get_class() and __CLASS__ cause PHP5 to behave erratically. Sometimes changes the data within the [argument] object and often causes Apache to crash.

Problems experienced on Windows XP. Same problem also caused a Dual Processor Mac OS-X box to soak up CPU time 1 processor. Script calls get_class() many, many times or complex, composite objects.

The erratic behaviour is very hard to pin down but the source is definitely get_class(). PHP5 objects are not very happy with this function.

Reproduce code:
I can say:

print get_class($object);

Expected result:
1) object dump
2) Name of object
3) same object dump

Actual result:
1) object dump
2) Name of object
3) object dump with probably one property changed

No other code in the middle to cause this behaviour.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-26 23:08 UTC] thought at phenomind dot com
Problems also with get_object_vars()

If my script has this function anywhere, PHP5 produces erratic results.
 [2003-12-26 23:41 UTC]
Can you post an example that actually reproduces?  A simple 
class used with your code runs fine on OS X.
 [2003-12-26 23:48 UTC] thought at phenomind dot com
Sorry, I cannot but I just removed 500+ instances of get_class() and __CLASS__ from many libraries of code and the problem has disappeared.

I'll give you an example of the object where the primary_key property was corrupted. It is fine in this instance because I have already done the abovementioned alterations:

user_session Object
    [y_resolution] => 
    [x_resolution] => 
    [flash_version] => 
    [session_identifier] => 
    [timestamp_difference] => 
    [cookies_enabled] => 
    [ip_address] => 
    [browser] => 
    [nominated_transport_agent_key] => 
    [nominated_shipper_key] => 
    [nominated_project_key] => 
    [live_key] => 73
    [new_on_load] => 
    [table_name] => user_sessions
    [composite_object_name] => 
    [composite_key] => 
    [primary_key] => user_session_key
    [database] => mysql_db Object
            [engine] => mysql
            [username] => ****
            [password] => *********
            [service_name] => 
            [live_table] => 
            [commit_query] => 0
            [tns_admin] => 
            [vars] => vars Object
                    [username] => ******
                    [btn_login] => Login
                    [password] => ****
                    [encoded_php_self] => 

            [database_name] => BKCARGO
            [host] => localhost
            [port] => 3306
            [host_port] => localhost:3306
            [database_handle] => Resource id #80
            [query] => UPDATE user_sessions SET user_key = '1', 
transport_agent_key = '', 
shipper_key = '', 
project_key = '', 
y_resolution = '', 
x_resolution = '', 
flash_version = '', 
session_identifier = '', 
timestamp_difference = '', 
cookies_enabled = '', 
ip_address = '', 
browser = '', 
live_user_key = '1'
 WHERE user_session_key='73'
            [result_handle] => 1

    [vars] => vars Object
            [username] => ********
            [btn_login] => Login
            [password] => *******
            [encoded_php_self] => *****

    [user_key] => 1
    [user_session_key] => 73
    [live_user_key] => 1
 [2003-12-29 22:36 UTC] thought at phenomind dot com
Okay. I think I may have some snippets of code to demonstrate this:

I have defined a two dimensional array like this:
$this->composite_object_names[0]    = "piece";
$this->composite_object_names[1]    = "pod_log";

Yet when I do a print_r on the object, I am getting this:

    [composite_object_names:public] => Array
            [0] => Diece
            [1] => Dod_log

I have numerous instances of get_class() and __CLASS__ scattered throughout my code. I know that if I remove this, the object will be fine. I am also suspicious of the get_object_vars() function but that it is almost impossible for me to quantify which one of these functions is at the root of the problem.

There is a bug here
 [2003-12-29 22:37 UTC] thought at phenomind dot com
Apologies. I meant two-element array. Not two-dimensional!
 [2003-12-29 22:48 UTC] thought at phenomind dot com
I will close this bug until I can get more specific, reproducable results.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 08:01:32 2024 UTC