WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#19681 closed enhancement (wontfix)

Plugin update hook

Reported by: olliea95 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords: close
Focuses: Cc:

Description

A hook similar to the register_activation_hook() should be provided for plugin updating. As far as I can see neither of the activation/deactivation hooks are called when updating a plugin through the WP admin updater. No easy way to run certain database updates etc. when a plugin is updated.

Change History (7)

#1 @sterlo
10 years ago

  • Cc sterling.hamilton+wordpresstrac@… added

#2 @scribu
10 years ago

  • Component changed from General to Plugins
  • Type changed from feature request to enhancement

#3 @johnbillion
10 years ago

  • Keywords close added

If a plugin is manually updated then this upgrade hook won't fire. The best way to manage database upgrades is to do it the same way as WordPress does it. Store an option containing your plugin's database version and check it on the admin_init hook and run the upgrade routine when it doesn't match the version in your plugin. Many popular plugins use this method. It's definitely the most fool-proof.

#4 @sterlo
10 years ago

To me it's odd that during the upgrade process, the plugin is deactivated and activated but neither of those hooks are actually fired.

#5 @dd32
10 years ago

To me it's odd that during the upgrade process, the plugin is deactivated and activated but neither of those hooks are actually fired.

That was the original case, But then too many plugins were removing data on the deactivation hook, or interrupting the process by doing crazy things, so then only the activation hook was fired, Then plugins were still messing it up by redirecting off elsewhere or doing way too much processing/not checking on activations. Finally, since most plugins were doing the right thing of storing a "database version" and checking for it on admin_init, to work around the fact people could manually update their plugins, it was easier to just not fire either of them, and leave them specifically for Activation/Deactivation purposes.

A upgrade hook such as this is overall pretty useless, for 2 reasons, 1. The plugin may rely on it, and break when someone performs a manual upgrade, and 2. At the time the hook would be run (ie. during the update process) the old plugin would be loaded in memory, not the newer version, which would mean waiting for the next page load to be able to fire it, and then you've got to deal with multiple plugins updating at once and affecting eachother, and future core alterations to updates..

My point is, there's a lot more to it, than just firing an action when a plugin is updated.. Theres numerous tickets on this suggestion too, and they always come back to the same points and get closed as wontfix..

#6 follow-up: @scribu
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Yeah, we've been over this far too many times already.

#7 in reply to: ↑ 6 @duck_
10 years ago

Xref #14912 for example of previous discussion.

Note: See TracTickets for help on using tickets.