WPBones icon indicating copy to clipboard operation
WPBones copied to clipboard

Activation by register_activation_hook starts just one time

Open gfazioli opened this issue 1 year ago • 0 comments

I have ran into an issue with migrations/seeders and the way it is called via register_activation_hook. This hook is only called after activation and it is not called after updating the plugin (I use a plugin called Git Updater for plugin version updates but I think it is the same for WP.org repositories). It makes some sense though that the activation hook is not called when updating the plugin.

But most of the times, migrations and seeders are added time by time during plugin version updates. So migrations & seeders must run after the plugin got updated as well. (More details in the thread.) Balazs Nasz — 22/06/2024 02:45 I have found a hook upgrader_process_complete which fires after any updates have completed. They have a caution though: Use with caution: When you use the upgrader_process_complete action hook in your plugin and your plugin is the one which under upgrade, then this action will run the old version of your plugin.

For this warning I have seen a solution: https://gist.github.com/junaidtk/dca0f58b5621b87167a9cf344cf86148

Update: upgrader_post_install seems better because at that time the updates are already finished so don't have to deal with that caution.

@balazsnasz created the issue

gfazioli avatar Jun 27 '24 14:06 gfazioli