php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23459 Contents of private variables are available in inheriting classes.
Submitted: 2003-05-02 19:10 UTC Modified: 2003-06-08 13:54 UTC
From: yoglets at hotmail dot com Assigned: zeev (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-05-02 (dev) OS: RH 7.3
Private report: No CVE-ID: None
 [2003-05-02 19:10 UTC] yoglets at hotmail dot com
Given:

<?php

class foo {
    private $message = 'this is a secret';
}

class bar extends foo {
}

$obj = new bar;
print_r($obj);

?>

Yields:

bar Object
(
    [] => this is a secret
)

While the variable in question is "unnamed" and can't be referenced directly (i.e., via $obj->message), its value _is_ available, which certainly seems counter-intuitive to its declaration of privacy.

This seems related to bug #23272, but I think it warrants its own ticket, as I believe it's more severe. (Especially considering the wasted memory allocation.)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-02 19:27 UTC] derick@php.net
I'll have a look at this...
 [2003-06-08 13:54 UTC] zeev@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC