has_action no reporting existing action hook
|Reported by:||firebird75||Owned by:|
I am trying to write a plugin which uses the has_action function. Unfortunately, it doesn't seem to be working under specific circunstances. It reports that the action isn't existing while it is thus allowing the action scheduling to be duplicated...
So he is what I am doing :
1/ First, I am registering and deregistering the plugin :
2/ Then we have both activation and deactivation functions :
wp_schedule_event(time(), 'hourly', 'myplugin_monthly_cron_hook');
So in the activation function, I am registering a hook for a cron task and then I am scheduling it and in the deactivation function, I am removing it.
Here is the scenario of the problem :
1/ Activate the plugin => the action hook is created and the associated cron action as well;
2/ Modify the plugin file (either by uploading a new one or by modifying it within the inline editor) without deactivating the plugin;
3/ This triggers the register_activation_hook function again (as the plugin file has been modified);
4/ Wordpress goes through myplugin_activation() and the (!has_action('myplugin_monthly_cron_hook','myplugin_monthly_cron')) test is entered while the action hasn't been removed (since the plugin wasn't deactivated manually). This is where the bug is, I cannot figure out why the has_action is returning false here while the action is indeed there...
I understand that this scenario will happen only when people updates the files without deactivating the plugin first. This isn't the right way to upgrade plugins but this can happen and so cause duplicate scheduling action registrations...