#31715 [NEW]: isset() and empty() return "Trying to get property of non-object"
| From: | cryptographite at comcast dot net | Date: | Thu, 27 Jan 2005 04:38:03 +0000 |
| Subject: | #31715 [NEW]: isset() and empty() return "Trying to get property of non-object" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-72911@lists.php.net to get a copy of this message | ||
From: cryptographite at comcast dot net
Operating system: FreeBSD
PHP version: 5.0.3
PHP Bug Type: Scripting Engine problem
Bug description: isset() and empty() return "Trying to get property of non-object"
Description:
------------
Using isset() or empty() on an unset child/parent object throws "Trying to
get property of non-object" errors.
This is contrary to the behavior of PHP 4 and makes no sense given the
purpose of the functions and their descriptions.
isset() and empty() should properly handle querying unset objects for
children without returning errors.
Reproduce code:
---------------
<?php
echo '$not->set->variable' . "\n";
echo isset($not->set->variable) ? 'isset true' : 'isset false';
echo "\n";
echo empty($not->set->variable) ? 'empty true' : 'isset false';
echo "\n------------------\n";
echo '$not->set[$key]' . "\n";
echo isset($not->set[$key]) ? 'isset true' : 'isset false';
echo "\n";
echo empty($not->set[$key]) ? 'empty true' : 'empty false';
echo "\n";
?>
Expected result:
----------------
Expected output: (No error messages)
$not->set->variable
isset false
empty true
------------------
$not->set[$key]
isset false
empty true
Actual result:
--------------
$not->set->variable
PHP Notice: Trying to get property of non-object in - on line 3
Notice: Trying to get property of non-object in - on line 3
isset false
PHP Notice: Trying to get property of non-object in - on line 5
Notice: Trying to get property of non-object in - on line 5
empty true
------------------
$not->set[$key]
PHP Notice: Undefined variable: key in - on line 9
Notice: Undefined variable: key in - on line 9
PHP Notice: Trying to get property of non-object in - on line 9
Notice: Trying to get property of non-object in - on line 9
isset false
PHP Notice: Undefined variable: key in - on line 11
Notice: Undefined variable: key in - on line 11
PHP Notice: Trying to get property of non-object in - on line 11
Notice: Trying to get property of non-object in - on line 11
empty true
--
Edit bug report at http://bugs.php.net/?id=31715&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31715&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31715&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31715&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31715&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31715&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31715&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31715&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31715&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31715&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31715&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31715&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31715&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31715&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31715&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31715&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31715&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31715&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31715&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31715&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31715&r=mysqlcfg