Opened 3 years ago
Last modified 6 months ago
#55101 new defect (bug)
pre_set_site_transient_update_plugins was called from deactivated plugin while uninstall.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Plugins | Keywords: | needs-patch |
Focuses: | Cc: |
Description
I have this sample plugin.
<?php /** * Plugin Name: A test */ class ATest { public function check() { error_log('pre_set_site_transient_update_plugins hook was called on ' . date('Y-m-d H:i:s')); } public function hooks() { add_filter ('pre_set_site_transient_update_plugins', [$this, 'check'], 10, 2); register_uninstall_hook(__FILE__, [__CLASS__, 'uninstall']); add_action('init', [$this, 'init']); } public function init() { error_log('init hook was called on ' . date('Y-m-d H:i:s')); } public function run() { $this->hooks(); } static public function uninstall() { error_log('uninstall method was called on ' . date('Y-m-d H:i:s')); } } $ATest = new \ATest(); $ATest->run();
When I click on delete plugin (the plugin is already deactivated), the pre_set_site_transient_update_plugins
hook was called.
To reproduce.
- Copy and paste the sample code above to new plugin file. For example test.php
- Go to your WordPress > admin > plugins.
- Activate this plugin.
- Go to your DB, delete
_site_transient_update_plugins
option name inoptions
table to make sure that this hook will be call next time. - Reload admin plugins page. This hook will be called as normal process because plugin is activated. The error log will be write to wp-contents/debug.log file.
- Deactive this plugin.
- Maybe try to reload plugins admin page again. The hook will not called from this plugin, no error log were write. This is correct.
- Click on delete this plugin.
- The error log were write because this hook is called while it is on uninstall process. This is incorrect!! It should not be called.
WordPress 6.0-alpha-52682
Change History (2)
Note: See
TracTickets for help on using
tickets.
Hello thanks for the report, i'm able to reproduce it.