ID: 32923
User updated by: m dot cappelleri at xaos dot it
Reported By: m dot cappelleri at xaos dot it
Status: Open
Bug Type: Scripting Engine problem
Operating System: Debian
PHP Version: 5.0.4
New Comment:
Sorry, the code example was already a workaround,
the code that generates the error is:
$this->_images = array();
while ($r = $q->fetchRow()){
try {
echo "Adding element ... <br/>";
$this->_images[] =
Attachment::Attachment($r['attachment_id'],
$r['type_id']);
} catch (xException $e) {
echo "<b>EX</b>";
}
}
echo "<pre>Ora lo printo...";
print_r($this->_images);
echo "</pre>";
Sorry about that.
Previous Comments:
------------------------------------------------------------------------
[2005-05-03 11:34:33] m dot cappelleri at xaos dot it
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 this bug report at http://bugs.php.net/?id=32923&edit=1