[wp-trac] [WordPress Trac] #10861: wpdb constructor and desctructor concept is broken

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 26 13:48:27 UTC 2009


#10861: wpdb constructor and desctructor concept is broken
--------------------------+-------------------------------------------------
 Reporter:  hakre         |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:  2.8.4     
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------

Comment(by hakre):

 The constructor (PHP 4, PHP 5) still might have errors. In case PHP 5
 prefers the class names function instead of the __construct() function
 (for example for backwards compability reasons, I was not able to clarify
 that in all details), the register_shutdown_function will be called with
 PHP 4 and PHP 5. It should only called with PHP 4.

 Additionally, having an empty function (wpdb::__destruct) does not make
 any sense. This leads to asking oneself: what is all the fuzz about?
 Constructor, Destructor, NIL. I assume this needs a cleanup.

 This would also lead to a solution for some other important point: Never
 register a __destruct function as a shutdown function. This will most
 often lead to problems (the function is called two times) and errors (the
 object is already destroyed when the shutdown function is (to be)
 executed).

 Therefore I suggest to remove this all from the object, I will provide a
 second patch for it.

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


More information about the wp-trac mailing list