[wp-trac] [WordPress Trac] #55101: pre_set_site_transient_update_plugins was called from deactivated plugin while uninstall.

WordPress Trac noreply at wordpress.org
Mon Feb 7 08:59:01 UTC 2022


#55101: pre_set_site_transient_update_plugins was called from deactivated plugin
while uninstall.
--------------------------+-----------------------------
 Reporter:  okvee         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.9
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I have this sample plugin.

 {{{#!php
 <?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.
 1. Copy and paste the sample code above to new plugin file. For example
 test.php
 2. Go to your WordPress > admin > plugins.
 3. Activate this plugin.
 4. Go to your DB, delete `_site_transient_update_plugins` option name in
 `options` table to make sure that this hook will be call next time.
 5. 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.
 6. Deactive this plugin.
 7. Maybe try to reload plugins admin page again. The hook will not called
 from this plugin, no error log were write. This is correct.
 8. Click on delete this plugin.
 9. 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55101>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list