#32923 [NEW]: Try and catch strange behaviour
| From: | m dot cappelleri at xaos dot it | Date: | Tue, 03 May 2005 09:34:34 +0000 |
| Subject: | #32923 [NEW]: Try and catch strange behaviour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-78557@lists.php.net to get a copy of this message | ||
From: m dot cappelleri at xaos dot it
Operating system: Debian
PHP version: 5.0.4
PHP Bug Type: Scripting Engine problem
Bug description: Try and catch strange behaviour
Description:
------------
In a try and catch syntax,
when an Exception is thrown a variable strangely disappears.
Reproduce code:
---------------
$this->_images = array();
while ($r = $q->fetchRow()){
try {
$tmp = NULL;
echo "Adding element ... <br/>";
$tmp = Attachment::Attachment($r['attachment_id'], $r['type_id']);
if (!isNull($tmp)) {
$this->_images[] = $tmp;
}
} catch (xException $e) {
echo "<b>EX</b>";
}
}
echo "<pre>Ora lo printo...";
print_r($this->_images);
echo "</pre>";
Expected result:
----------------
$this->_images SHOULD ALWAYS be an array, no matter when or if an
exception is thrown.
Actual result:
--------------
In this case when the exception is thrown in the last cycle the print_r
gives a null result.
Even more strangely, $this->_images is still there and correctly populated
when requested after that (from a different method).
--
Edit bug report at http://bugs.php.net/?id=32923&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32923&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32923&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32923&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32923&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32923&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32923&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32923&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32923&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32923&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32923&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32923&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32923&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32923&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32923&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32923&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32923&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32923&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32923&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32923&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32923&r=mysqlcfg