[wp-trac] [WordPress Trac] #31496: register_uninstall_hook tries to serialize anonymous functions

WordPress Trac noreply at wordpress.org
Mon Mar 2 16:45:34 UTC 2015


#31496: register_uninstall_hook tries to serialize anonymous functions
--------------------------------+------------------------------
 Reporter:  giuseppe.mazzapica  |       Owner:
     Type:  defect (bug)        |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Plugins             |     Version:
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:
--------------------------------+------------------------------

Comment (by giuseppe.mazzapica):

 Replying to [comment:1 dd32]:
 > Could we simply reject anything that isn't a string?

 Well, static methods in array should be fine. We can make the check opt-in
 instead of opt-out:


 {{{
 function register_uninstall_hook( $file, $callback ) {
     if ( is_string( $callback ) || ( is_array( $callback ) && is_string(
 $callback[0] ) ) ) {
         $uninstallable_plugins = (array) get_option('uninstall_plugins');
         $uninstallable_plugins[plugin_basename($file)] = $callback;
         update_option('uninstall_plugins', $uninstallable_plugins);
         return;
     }
     _doing_it_wrong( __FUNCTION__, __( 'Only a static class method or
 function...' ), '3.1' );
 }
 }}}

 If it makes any difference...

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


More information about the wp-trac mailing list