From:             andreigurin at tiscali dot it
Operating system: windows xp sp2 / linux centos / 
PHP version:      4.4.2
PHP Bug Type:     Class/Object related
Bug description:  $this visibility violated

Description:
------------
$this keyword visibility is violated if accessed from a function external
to a class. This happens in 4.xxx versions, and in 5.xxx, Tested on Window
2000, Windows Xp sp2, Linux Centos(3.7?), Red hat, and some other Linux
based systems

Reproduce code:
---------------
class Foo {
    private $__prv;
    public function __constructor($v) {
        $this->__prv = $v;
    }
    public function do_something() {
        bla bla bla...
        hack();
    }
    public function prv() {
        return $this->__prv;
    }
}
function hack() {
    $this->__prv = 'A very bad value!';
}
$foo = new Foo('A good __prv value');
$foo->do_something();
print $foo->prv();

Expected result:
----------------
Triggered error: 
bla bla bla undefined variable this in file.php on line ...
Output:
A good __prv value

Actual result:
--------------
Output:
A very bad value

-- 
Edit bug report at http://bugs.php.net/?id=36707&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36707&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36707&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36707&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36707&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36707&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36707&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36707&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36707&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36707&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36707&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36707&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36707&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36707&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36707&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36707&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36707&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36707&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36707&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36707&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36707&r=mysqlcfg

Reply via email to