Consider the following script run for a URL that's known not to contain a valid WSDL:
<?php
echo "start
";
try {
$test = new SoapClient ('http://www.example.com/');
} catch (Exception $e) {
echo "Caught exception
";
}
echo "end
";
As expected, it logs out the following when run:
start
Caught exception
end
so the script did run to completion in spite failing to connect to a SOAP server. This is exactly what I was expecting. What I didn't expect was the following also getting logged to /var/log/php_error:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in 'http://www.example.com/' in soapfail.php on line 6
if you have display_errors turned on, the result just looks plain bizarre.
start
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.example.com/' : Extra content at the end of the document
in soapfail.php on line 6
Caught exception
end
It seems that in this case, PHP is emitting a fatal error even though the script didn't stop execution at that point. Obviously this is a hugely simplified and contrived example, but I discovered this behaviour in a live system that was doing SOAP requests against a server that had gone down. The fatal errors showing up in the log led us to believe that we were failing to handle an error properly, when in fact it seems that PHP is just emitting a fatal error notification when it shouldn't be.
Is there anything I can do about this behaviour other than turning off logging (which really isn't an option)?
UPDATE: The PHP version I'm using, for completeness, is:
PHP 5.4.6-1ubuntu1.5 (cli) (built: Dec 12 2013 04:39:44) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
I also tested this on my home machine with similar results.
PHP 5.5.5 (cli) (built: Oct 20 2013 23:15:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
UPDATE 2:
I filed a bug report because this just doesn't seem correct to me. Report on php.net