Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33534 closed defect (bug) (invalid)

Activation hook doesn't get called with the new plugin update?

Reported by: amonad's profile amonad Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

With the new update mechanism, where the user can update the plugin from the plugin list screen itself. The activation hook doesn't seem to get triggered with this approach. Has this feature been deprecated because previously when the plugin was updated it used to follow these steps:

1) Deactivate plugin
2) Delete old plugin files
3) Install new plugin files
4) Activate the plugin.

I'm asking this because I need to add some new features in the new version of the plugin and that feature needs to save some default parameters in the db. I'm putting this code in the activation code which gets called when the plugin is activated. It's not working this way. Is there a new way I should handle such things in future?

Please help.

Change History (1)

#1 @swissspidy
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 4.2.3 to 3.1

Since WordPress 3.1, this hook is fired only when the user activates the plugin and not when an automatic plugin update occurs. See #14915.

You need to manually detect plugin updates in your code. Quote from this announcement post:

The proper way to handle an upgrade path is to only run an upgrade procedure when you need to. Ideally, you would store a “version” in your plugin’s database option, and then a version in the code. If they do not match, you would fire your upgrade procedure, and then set the database option to equal the version in the code. This is how many plugins handle upgrades, and this is how core works as well.

Note: See TracTickets for help on using tickets.