ZF2-144: Zend\Stdlib\PriorityQueue clone problem

Issue Type: Bug Created: 2012-01-21T17:08:32.000+0000 Last Updated: 2012-03-29T18:29:40.000+0000 Status: Resolved Fix version(s): Reporter: Tautvydas Andrikys (esminis) Assignee: Andries Seutens (andries) Tags: Related issues: Attachments: - zf.patch


When cloning Zend\Stdlib\PriorityQueue its property queue is not cloned so all cloned objects will have same queue object. This will couse double execution of event listeners in some cases for EventManager and probably lots of other problems in other components.


Posted by Tautvydas Andrikys (esminis) on 2012-01-21T17:08:59.000+0000


Posted by Andries Seutens (andries) on 2012-03-26T19:01:00.000+0000

When an object is cloned, PHP 5 will perform a shallow copy of all of the object's properties. Any properties that are references to other variables, will remain references.

Thus your patch is not correct, as the references in the $items property will remain references.

I have created a pull request with a proper patch:

Posted by Andries Seutens (andries) on 2012-03-26T21:09:02.000+0000

Actually, you were right.

Posted by Tautvydas Andrikys (esminis) on 2012-03-27T15:16:41.000+0000

Yes couse you can`t unserialize(serialize()) on \SplPriorityQueue object. Also, most important, I want only references cloned not whole objects(deep copy would be incorrect in this case from my perspective).

Posted by Andries Seutens (andries) on 2012-03-27T17:05:52.000+0000

Yes, you were right. I have updated the pull request, to reflect those changes.

Posted by Andries Seutens (andries) on 2012-03-29T18:27:00.000+0000

Issue has been merged into master, and can be closed. Thank you for your feedback.…

Posted by Andries Seutens (andries) on 2012-03-29T18:29:40.000+0000

Accidently clicked "close issue" instead of "resolve issue". Resolving now.

Have you found an issue?

See the Overview section for more details.


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

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