[PHP-BUG] Bug #51479 [NEW]: property_exists now wrong
[email protected] ("ian at ianhobson dot co dot uk") Mon, 5 Apr 2010 15:26:43 +0200 (CEST)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From:
Operating system: Windows
PHP version: 5.3.2
Package: Class/Object related
Bug Type: Bug
Bug description:property_exists now wrong
Description:
------------
Now that property_exists returns true for all private properties, there is
no way (I know) to test that a property is private before writing to it and
causing a fatal error.
The previous behaviour was wrong - private properties that are in scope
should return true - but the new code is worse.
See Bug #50810: property_exists does not work for private
I think property_exists should return true for writable properties...
which implies a scope...
if the user coded $this then the scope is the current scope.
If the use gives a class name, then the scope is that class.
I have not managed to re-code the routine below to work in 5.3.0 (let alone
both 5.3.? and 5.2.?).
Test script:
---------------
public function setField($fld, $value) {
// set the fld to the value
if (property_exists($this,$fld)) {
$this->$fld = $value; // handles public and protected fields
return;
}
$this->setMapped($fld,$value); // for private vars.
}
Create a class with the above function. Create a sub-class with a private
variable. Call it on the sub-class with fldname and value.
In 5.3.0 this crashes with a fatal error.
In 5.2.9 it calls setMapped.
--
Edit bug report at http://bugs.php.net/bug.php?id=51479&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51479&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51479&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51479&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51479&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51479&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51479&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51479&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51479&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51479&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51479&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51479&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51479&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51479&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51479&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51479&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51479&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51479&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51479&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51479&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51479&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51479&r=mysqlcfg