Issues

ZF-12223: Zend_Amf_Server::setClass() fails after duplicate class registration attempt

Description

Zend_Amf_Server::setClass() (actually it is _buildDispatchTable()) throws a 'Duplicate method registered: ' exception on a duplicate class registration attempt, which is fine. But the problem is it "remembers" the situation, and therefore it is not possible to register any more classes afterwards.

Sample code:

{quote} $server = new Zend_Amf_Server(); $server->setClass("Class1"); try { $server->setClass("Class1"); } catch (Exception $e) { // Swallow "Duplicate method ..." exception } $server->setClass("Class2");

print_r($server->listMethods()); {quote}

The exception is swallowed at the second attempt of registering Class1, so registering Class2 should be successfull, but it is not, the 'Duplicte ...' exception is thrown again.

Possible problem: In Zend_Amf_Server::setClass() on line 780 the new class is added to the _methods[] array regardless of the registration success. And if _method[] has more than one item for the same class, from that point _buildDispatchTable() will always fail, even if a different class is coming.

Possible fix: Remove the last item from _method[] if _buildDispatchTable() throws an exception.

Comments

No comments to display