Edit report at http://bugs.php.net/bug.php?id=46792&edit=1
ID: 46792 Comment by: clockw...@php.net Reported by: daniel dot oconnor at gmail dot com Summary: SoapFault detail property missing Status: Bogus Type: Bug Package: SOAP related Operating System: Windows PHP Version: 5.2.7 Assigned To: dmitry Block user comment: N New Comment: Another variant: PHP 5.2.13, somehow someone is raising soapfaults without a faultcode (or it's null, or something); which is being raised by the soapclient object. try { $sc = new SoapClient(...); $sc->foo(); } catch (SoapFault $sf) { var_dump($sf->faultcode); // E_NOTICE! } This results in: Undefined property: SoapFault::$faultcode in /var/www/vx/include/classes/queue/OrderAction.php on line 19 when you try and check it. Given that the constructor requires you to provide a faultcode (http://au.php.net/soapfault); if the soapfault object doesn't set default properties, at least ensure where it's invoked by the soapclient passes in the right parameters. It's the same scenario as the original report; just a different property. Previous Comments: ------------------------------------------------------------------------ [2009-04-25 17:42:56] daniel dot oconnor at gmail dot com I still feel it should be defined all of the time, and just set to null if there's nothing there; like every other object in PHP. As a normal developer, I shouldn't have to remember that if I want to check my soapfault detail I have to wrap it in isset(), because this is one of the few niche bits of PHP which break convention. This bug exposes two seperate problems - class definition and how that object is rendered. My problem is with the class definition/instatiation not fitting with how every other class I know of behaves. For your problems, with rendering/encoding soapfault detail needlessly, why not just check if the property is null or not in the encoding step? And if its that big of a concern, what about spinning of another ticket to specifically deal with that? ------------------------------------------------------------------------ [2009-04-25 16:20:10] j...@php.net As Dmitry said. Use isset(). ------------------------------------------------------------------------ [2009-01-11 10:56:45] daniel dot oconnor at gmail dot com Not having the property defined was surprising, and unexpected - I would not expect code which reads SoapFault::$detail to ever generate an E_NOTICE. ------------------------------------------------------------------------ [2009-01-11 09:40:03] dmi...@php.net I don't think we should create empty "detail" property (and then encode it and send back to client) if it's not important. Very rare script looks into fault details. In case your script really needs it, it can always check it with isset() or empty(). ------------------------------------------------------------------------ [2008-12-31 17:39:13] fel...@php.net Hi Dmitry, any objection? http://felipe.ath.cx/diff/bug46792.diff ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=46792 -- Edit this bug report at http://bugs.php.net/bug.php?id=46792&edit=1