[wp-trac] [WordPress Trac] #50799: Clean orphaned custom database tables

WordPress Trac noreply at wordpress.org
Tue Jul 28 18:22:26 UTC 2020


#50799: Clean orphaned custom database tables
-----------------------------+------------------------------
 Reporter:  stuffradio       |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Site Health      |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Old description:

> There was a ticket I just commented today where someone suggested forcing
> a plugin developer to use the deactivation hook and cleaning the custom
> created tables. I pointed out how some people might want to keep some
> data in case they want to activate the plugin again in the future and
> still have their data.
>
> My idea is to create a section in Site Health where it lists all the non-
> standard WordPress tables and the plugin that created the tables so an
> administrator could clean up their database from the admin panel. Another
> part to this could be to slightly alter the plugin deactivation to have a
> hard and soft deactivate/delete plugin link where the soft
> delete/deactivate would simply remove the plugin, and the hard
> delete/deactivate would delete the associated tables and data.
>
> I'm open to suggestions/feedback on this idea.

New description:

 There was a ticket I just commented today (#46832) where someone suggested
 forcing a plugin developer to use the deactivation hook and cleaning the
 custom created tables. I pointed out how some people might want to keep
 some data in case they want to activate the plugin again in the future and
 still have their data.

 My idea is to create a section in Site Health where it lists all the non-
 standard WordPress tables and the plugin that created the tables so an
 administrator could clean up their database from the admin panel. Another
 part to this could be to slightly alter the plugin deactivation to have a
 hard and soft deactivate/delete plugin link where the soft
 delete/deactivate would simply remove the plugin, and the hard
 delete/deactivate would delete the associated tables and data.

 I'm open to suggestions/feedback on this idea.

--

Comment (by SergeyBiryukov):

 Hi there, welcome back to WordPress Trac! Thanks for the ticket.

 > Another part to this could be to slightly alter the plugin deactivation
 to have a hard and soft deactivate/delete plugin link where the soft
 delete/deactivate would simply remove the plugin, and the hard
 delete/deactivate would delete the associated tables and data.

 Just noting that plugins can already do this by using one of the
 [https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/
 uninstall methods] instead of a deactivation hook.

 As noted in the [https://developer.wordpress.org/plugins/plugin-basics
 /activation-deactivation-hooks/ plugin handbook]:
 > The deactivation hook is sometimes confused with the
 [https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/
 uninstall hook]. The uninstall hook is best suited to **delete all data
 permanently** such as deleting plugin options and custom tables, etc.

 Related: #50346

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50799#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list