PhP shell execute ignores Exceptions

I have the strangest bug. I was like wtf^12.

I have a script wchich calls following function:

function checkNewFilename($newFilename)
{
    if (file_exists($newFilename)) {

        if (!unlink($newFilename)) {
            debugDeploy($newFilename . ' already exists and could not be deleted.');
            throw new Exception($newFilename . ' already exists and could not be deleted.');
        }
    }
}

It gets used like this:

$newFilename = $defaultConfig . DIRECTORY_SEPARATOR . 'client.xml'; 
checkNewFilename($newFilename);
echo 'wtf is happening here';
copy($configFilename, $newFilename);

Now when i run this code with normall browser/xdebug i get a cachable fatal error as it should be. BUT when i run the script via shell on

php script.php param param param 

Somthing nuts happens. IT ignores the exceptions and gous as nothing happend. I get the error before the exception AND the echo after the function call... wth.

I am runing on

PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug 6 2012 14:18:06) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

Anyone has any idea what causes this strange behavior?

链接地址: http://www.djcxy.com/p/65084.html

上一篇: PhP触及不存在的文件返回true

下一篇: PhP shell执行忽略异常