WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#50799 new feature request

Clean orphaned custom database tables

Reported by: stuffradio Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Site Health Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

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.

Change History (2)

#1 follow-up: @SergeyBiryukov
3 months ago

  • Description modified (diff)

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 uninstall methods instead of a deactivation hook.

As noted in the plugin handbook:

The deactivation hook is sometimes confused with the uninstall hook. The uninstall hook is best suited to delete all data permanently such as deleting plugin options and custom tables, etc.

Related: #50346

#2 in reply to: ↑ 1 @stuffradio
3 months ago

Replying to 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 uninstall methods instead of a deactivation hook.

As noted in the plugin handbook:

The deactivation hook is sometimes confused with the uninstall hook. The uninstall hook is best suited to delete all data permanently such as deleting plugin options and custom tables, etc.

Related: #50346

What do you think about the idea of having an "orphaned" table section in site health that shows all the tables un-associated with a plugin, or just something that shows all the tables not created by WordPress itself so a person can decide whether they want to "clean"(remove) that table and free up more resources?

Note: See TracTickets for help on using tickets.