[wp-trac] [WordPress Trac] #46038: Exiting during the WSoD shutdown handler prevents all other shutdown handlers from being called

WordPress Trac noreply at wordpress.org
Mon Jan 21 06:10:36 UTC 2019


#46038: Exiting during the WSoD shutdown handler prevents all other shutdown
handlers from being called
------------------------------------+---------------------
 Reporter:  johnbillion             |       Owner:  (none)
     Type:  defect (bug)            |      Status:  new
 Priority:  high                    |   Milestone:  5.1
Component:  Bootstrap/Load          |     Version:  trunk
 Severity:  normal                  |  Resolution:
 Keywords:  needs-patch servehappy  |     Focuses:
------------------------------------+---------------------

Comment (by schlessera):

 I'm currently investigating how to solve this. But first of all, I'd like
 to address the issue of the DB/Cache destructors mentioned above.

 According to the PHP manual:

 > The destructor will be called even if script execution is stopped using
 exit(). Calling exit() in a destructor will prevent the remaining shutdown
 routines from executing.

 So, while we do need to address the `exit()` we have in our WSOD
 protection, I don't understand why there are "shutdown handlers" to call
 the destructors in the first place. That seems like a PHP-4-era left-over.
 The entire point of having destructors is that you can rely on them being
 called.

 Furthermore, the only thing the Core-provided destructors do is `return
 true;`. If you look at the signature from the PHP manual, one can see that
 this is a bug: destructors are not meant to return anything:

 > `__destruct ( void ) : void`

 This makes perfect sense, as they are not meant to be directly called
 anyway.

 So I suggest creating two follow-up bug tickets:
 - Do not register shutdown handlers to call destructors explicitly
 - Adapt `wpdb::__destruct()` and `WP_Object_Cache::__destruct()`
 signatures and code to have a return type of `void`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46038#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list