Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 1a065a8

Browse files
committed
Fixes magento#32 - Zend_Soap_Client has no exceptions flag
1 parent 26d8274 commit 1a065a8

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

library/Zend/Soap/Client.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Zend_Soap_Client
8989
protected $_features = null;
9090
protected $_cache_wsdl = null;
9191
protected $_user_agent = null;
92+
protected $_exceptions = null;
9293

9394
/**
9495
* WSDL used to access server
@@ -268,6 +269,9 @@ public function setOptions($options)
268269
case 'user_agent':
269270
$this->setUserAgent($value);
270271
break;
272+
case 'exceptions':
273+
$this->setExceptions($value);
274+
break;
271275

272276
// Not used now
273277
// case 'connection_timeout':
@@ -315,13 +319,14 @@ public function getOptions()
315319
$options['cache_wsdl'] = $this->getWsdlCache();
316320
$options['features'] = $this->getSoapFeatures();
317321
$options['user_agent'] = $this->getUserAgent();
322+
$options['exceptions'] = $this->getExceptions();
318323

319324
foreach ($options as $key => $value) {
320325
/*
321326
* ugly hack as I don't know if checking for '=== null'
322327
* breaks some other option
323328
*/
324-
if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) {
329+
if (in_array($key, array('user_agent', 'cache_wsdl', 'compression', 'exceptions'))) {
325330
if ($value === null) {
326331
unset($options[$key]);
327332
}
@@ -908,6 +913,39 @@ public function getUserAgent()
908913
return $this->_user_agent;
909914
}
910915

916+
/**
917+
* Set the exceptions option
918+
*
919+
* The exceptions option is a boolean value defining whether soap errors
920+
* throw exceptions.
921+
*
922+
* @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters
923+
*
924+
* @param bool $exceptions
925+
* @return $this
926+
*/
927+
public function setExceptions($exceptions)
928+
{
929+
$this->_exceptions = (bool) $exceptions;
930+
931+
return $this;
932+
}
933+
934+
/**
935+
* Get the exceptions option
936+
*
937+
* The exceptions option is a boolean value defining whether soap errors
938+
* throw exceptions.
939+
*
940+
* @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters
941+
*
942+
* @return bool|null
943+
*/
944+
public function getExceptions()
945+
{
946+
return $this->_exceptions;
947+
}
948+
911949
/**
912950
* Retrieve request XML
913951
*

tests/Zend/Soap/ClientTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,42 @@ public function testAllowNumericZeroAsValueForCompressionOptions()
260260
$this->assertArrayNotHasKey('compression', $options);
261261
}
262262

263+
/**
264+
* @group GH-32
265+
*/
266+
public function testGetAndSetExceptionsOption()
267+
{
268+
$client = new Zend_Soap_Client();
269+
$this->assertNull($client->getExceptions());
270+
$this->assertEquals(
271+
array(
272+
'encoding' => 'UTF-8',
273+
'soap_version' => 2,
274+
),
275+
$client->getOptions()
276+
);
277+
278+
$client->setExceptions(true);
279+
$this->assertTrue($client->getExceptions());
280+
281+
$client->setExceptions(false);
282+
$this->assertFalse($client->getExceptions());
283+
284+
$client->setOptions(array('exceptions' => true));
285+
$this->assertTrue($client->getExceptions());
286+
287+
$client = new Zend_Soap_Client(null, array('exceptions' => false));
288+
$this->assertFalse($client->getExceptions());
289+
$this->assertEquals(
290+
array(
291+
'encoding' => 'UTF-8',
292+
'soap_version' => 2,
293+
'exceptions' => false,
294+
),
295+
$client->getOptions()
296+
);
297+
}
298+
263299
public function testGetFunctions()
264300
{
265301
$server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl');

0 commit comments

Comments
 (0)