[wp-trac] [WordPress Trac] #14912: Introduce register_upgrade_hook()

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 21 00:56:59 UTC 2010

#14912: Introduce register_upgrade_hook()
 Reporter:  scribu           |       Owner:                
     Type:  enhancement      |      Status:  new           
 Priority:  normal           |   Milestone:  Future Release
Component:  Upgrade/Install  |     Version:                
 Severity:  normal           |    Keywords:  needs-patch   

Comment(by ericmann):

 This patch does a couple of things.  Firstly, it adds an option called
 `active_plugin_versions` that maps plugin file names to their current
 version.  The key/value pair is added to the database when the plugin is
 first activated.

 WordPress will check the plugin's version against its stored database
 value whenever `register_update_hook` is called.  It's getting the
 expected (current) version number from the function call itself and the
 stored version number from `get_option` ... no need to re-parse plugin
 headers.  If the expected version is higher than the value stored in the
 database, WordPress assumes an update and fires the `update-
 plugin_{pluginname}` action.

 The function `register_update_hook` accepts three parameters - the plugin
 filename, a callback function, and the plugin version the system is
 expecting - this version should be the same as the current version of the
 plugin and is explicitly set by the plugin.

 I've done some preliminary testing by tweaking the version number of Hello
 Dolly to see how things work.  It seems to be working just fine so far.

 Unfortunately, it only works for single sites at the moment ... I'm not up
 to speed with MS development yet, so I didn't even touch the
 `active_sitewide_plugins` settings, though I'm open to advice and guidance

Ticket URL: <http://core.trac.wordpress.org/ticket/14912#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list