From: florian dot mueller at hostpoint dot ch Operating system: freebsd 9.2 PHP version: 5.5.4 Package: CGI/CLI related Bug Type: Bug Bug description:Func returns NULL if last stmt is 'Exception' or 'die' inside unreachable else
Description: ------------ Important: The problem occurs only with php-cgi binary and not with php binary. The problem is, that the following snipped returns NULL instead of true. My guess is, that it has to do with a) if($variable) and b) the fact that "throw new Exception" is the last expression before return. function testMinimal(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } return true; } A attached a test script with several cases. For example this one returns NULL as well: function testMinimalDie(){ $foo = true; if($foo){ echo ''; } else { die(); } return true; } whereas those two work: function testMinimalNoVar(){ if(true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalHack(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } $someUnrelatedVariable=1; return true; } Test script: --------------- <?php echo "testMinimal "; var_dump(testMinimal()); echo "testMinimalOk "; var_dump(testMinimalOk()); echo "testMinimalNoEx "; var_dump(testMinimalNoEx()); echo "testMinimalDie "; var_dump(testMinimalDie()); echo "testMinimalDivZero "; var_dump(testMinimalDivZero()); echo "testMinimalNoVar "; var_dump(testMinimalNoVar()); echo "testMinimalEEE "; var_dump(testMinimalEEE()); echo "testMinimalEE "; var_dump(testMinimalEE()); echo "testMinimalReturnFalse "; var_dump(testMinimalReturnFalse()); echo "testMinimalHack "; var_dump(testMinimalHack()); function testMinimal(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalHack(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } $someUnrelatedVariable=1; return true; } function testMinimalEEE(){ $foo = true; if($foo===true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalEE(){ $foo = true; if($foo==true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalNoVar(){ if(true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalReturnFalse(){ if(true){ echo ''; } else { return false; } return true; } function testMinimalNoEx(){ $foo = true; if($foo){ echo ''; } else { echo 'gugus'; } return true; } function testMinimalDie(){ $foo = true; if($foo){ echo ''; } else { die(); } return true; } function testMinimalDivZero(){ $foo = true; if($foo){ echo ''; } else { 0/0; } return true; } function testMinimalOk(){ $foo = true; if($foo){ echo ''; } return true; } ?> Expected result: ---------------- testMinimal bool(true) testMinimalOk bool(true) testMinimalNoEx bool(true) testMinimalDie bool(true) testMinimalDivZero bool(true) testMinimalNoVar bool(true) testMinimalEEE bool(true) testMinimalEE bool(true) testMinimalReturnFalse bool(true) testMinimalHack bool(true) Actual result: -------------- testMinimal NULL testMinimalOk bool(true) testMinimalNoEx bool(true) testMinimalDie NULL testMinimalDivZero bool(true) testMinimalNoVar bool(true) testMinimalEEE NULL testMinimalEE NULL testMinimalReturnFalse bool(true) testMinimalHack bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=65812&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65812&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65812&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65812&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65812&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65812&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65812&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65812&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65812&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65812&r=support Expected behavior: https://bugs.php.net/fix.php?id=65812&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65812&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65812&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65812&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65812&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65812&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65812&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65812&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65812&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65812&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65812&r=mysqlcfg