Prevent infinite recursion in RpcLiteralRequestMessageBinder
This commit is contained in:
parent
08c51aebcf
commit
154863cc84
|
@ -81,9 +81,11 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
{
|
{
|
||||||
$hash = spl_object_hash($message);
|
$hash = spl_object_hash($message);
|
||||||
if (isset($this->messageRefs[$hash])) {
|
if (isset($this->messageRefs[$hash])) {
|
||||||
return $message;
|
return $this->messageRefs[$hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->messageRefs[$hash] = $message;
|
||||||
|
|
||||||
$r = new \ReflectionClass($message);
|
$r = new \ReflectionClass($message);
|
||||||
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
||||||
$p = $r->getProperty($type->getName());
|
$p = $r->getProperty($type->getName());
|
||||||
|
@ -101,6 +103,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->messageRefs[$hash] = $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -130,6 +130,25 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(array('foo' => array()), $result);
|
$this->assertEquals(array('foo' => array()), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProccessMessagePreventInfiniteRecursion()
|
||||||
|
{
|
||||||
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$foo = new Fixtures\FooRecursive('foo', '');
|
||||||
|
$bar = new Fixtures\BarRecursive($foo, 10394);
|
||||||
|
$foo->setBar($bar);
|
||||||
|
|
||||||
|
$result = $messageBinder->processMessage(
|
||||||
|
new Definition\Method('prevent_infinite_recursion', null, array(), array(
|
||||||
|
new Definition\Argument('foo_recursive', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive')),
|
||||||
|
)),
|
||||||
|
array($foo),
|
||||||
|
$this->getDefinitionComplexTypes()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(array('foo_recursive' => $foo), $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function messageProvider()
|
public function messageProvider()
|
||||||
{
|
{
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
@ -198,6 +217,14 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'] = $this->createComplexTypeCollection(array(
|
||||||
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'] = $this->createComplexTypeCollection(array(
|
||||||
|
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'),
|
||||||
|
));
|
||||||
|
|
||||||
return $definitionComplexTypes;
|
return $definitionComplexTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue