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

Issue Type: Bug Created: 2012-05-21T16:01:12.000+0000 Last Updated: 2012-05-21T16:01:12.000+0000 Status: Open Fix version(s): Reporter: Andras Janurik (janurika) Assignee: Wade Arnold (wadearnold) Tags: - Zend_Amf

Related issues: Attachments:


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.


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.