[wp-trac] [WordPress Trac] #11597: __destruct() is not designed to clean up circular references

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 2 05:04:53 UTC 2010


#11597: __destruct() is not designed to clean up circular references
--------------------------+-------------------------------------------------
 Reporter:  hakre         |        Owner:          
     Type:  defect (bug)  |       Status:  reopened
 Priority:  normal        |    Milestone:          
Component:  General       |      Version:  2.9     
 Severity:  normal        |   Resolution:          
 Keywords:  has-patch     |  
--------------------------+-------------------------------------------------

Comment(by Denis-de-Bernardy):

 Replying to [comment:11 hakre]:
 > Replying to [comment:8 Denis-de-Bernardy]:
 > > I'd have one tiny objection to the current patch: a __destruct()
 function that calls destroy() should be kept around.
 >
 > Since destroy() has to be called by user code whenever the object is to
 be unset, this should not be necessary - taken for granted that pattern is
 to be used here.

 then again, doing so *is* necessary when you've circular references. using
 unset, or even setting the object to null, just won't work.

 you can notice this by creating two objects, and giving each one a
 destructor. make the destructor call destroy(), and have that echo
 something. create A = new test, B = new test. A->b = B; B->a = A; then
 unset A and B, echo test, and watch how the script ends -- it'll call the
 two destructors when the script dies.

 calling the function destroy() or free() rather than destruct() is mostly
 cosmetic, and that I agree it's prettier is the only reason I'm not re-
 closing. then again, this ticket has been opened for 2 months with no
 apparent interest from core devs... or rather, it got two votes against
 from the new ones...

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11597#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list