[wp-trac] [WordPress Trac] #12754: register_uninstall_hook() doesn't allow multiple callbacks

WordPress Trac wp-trac at lists.automattic.com
Mon Mar 29 08:35:33 UTC 2010


#12754: register_uninstall_hook() doesn't allow multiple callbacks
--------------------------+-------------------------------------------------
 Reporter:  scribu        |       Owner:  westi    
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  3.0      
Component:  Plugins       |     Version:  3.0      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by nacin):

 Replying to [comment:8 scribu]:
 > My opinion is that having the ability to register multiple uninstall
 hooks is more useful than being able to use it outside the global scope.

 I disagreee, but that's not the issue. The issue is compatibility. It
 currently doesn't work with multiple callbacks, but it currently *does*
 work outside of global scope. Two fixes: 1) use uninstall.php instead, or
 2) we can make uninstall_plugins hold an array of callbacks. We should
 encourage the first (and do so in the inline docs and the Codex) and do
 the second.

 > Also, it's consistent with the other functions. At the very least, it
 should be clearly stated in the docs that it doesn't behave like the
 others.

 Technically, only register_activation_hook() needs to be run in global
 scope. Neither deactivation nor uninstall need to be.

 > Funny you should mention that. update_option() first does a $new_value
 === $old_value to see if it really needs to update the database.

 Fair enough. And it looks like it is autoloaded as well.

 >I was calling register_activation_hook() with an array($obj, 'method')
 callback. Because the current object instance didn't match the
 unserialized instance, it _did_ force multiple UPDATE queries on each page
 load.

 The docs should demand it be a function callback. Maybe a deprecated arg
 call to not like arrays.

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


More information about the wp-trac mailing list