From: phpbug-david at tulloh dot id dot au
Operating system: Debian Linux
PHP version: 5CVS-2005-11-24 (snap)
PHP Bug Type: CGI related
Bug description: cat | php -a has different behaviour to php -f
Description:
------------
Actually using php 5.1.0, final release.
PHP does not seem to handle exceptions correctly when called with php -a.
I have two test cases that demonstrate the problem with slightly different
output.
The tests were run with:
php -n -f test1.php
cat test1.php | php -n -a
Reproduce code:
---------------
test1.php:
<?php
class TC
{
public function __construct() {}
public function __set($name, $value) {
throw new Exception();
}
}
$tr = new TC();
$tr->first =4;
$tr2= new TC();
var_dump($tr2);
$tr2->first=9;
?>
test2.php:
<?php
class TC
{
public function __construct() {}
public function afunc() {
throw new Exception();
}
}
$tr = new TC();
$tr->afunc();
$tr2 = new TC();
var_dump($tr2);
$tr2->afunc();
?>
Expected result:
----------------
The php -n -f command produces the expected results:
Fatal error: Uncaught exception 'Exception' in test1.php:5
Stack trace:
#0 test1.php(10): TC::__set('first', 4)
#1 {main}
thrown in test1.php on line 6
Fatal error: Uncaught exception 'Exception' in test2.php:6
Stack trace:
#0 test2.php(11): TC->afunc()
#1 {main}
thrown in test2.php on line 6
Actual result:
--------------
cat test1.php | php -n -a produces:
Interactive mode enabled
NULL
Fatal error: Invalid opcode 137/1/8. in - on line 14
and test2:
Interactive mode enabled
NULL
Fatal error: Call to a member function afunc() on a non-object in
/home/lod/ecouch/full/objects/- on line 14
--
Edit bug report at http://bugs.php.net/?id=35360&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35360&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=35360&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=35360&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=35360&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35360&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35360&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35360&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35360&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35360&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35360&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35360&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35360&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35360&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35360&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35360&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35360&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35360&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35360&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35360&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35360&r=mysqlcfg