Make WordPress Core

Opened 3 years ago

Last modified 15 months ago

#46832 new enhancement

Notice or Warning if a plugin create table and do not delete them

Reported by: sebastienserre Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords: 2nd-opinion needs-patch dev-feedback
Focuses: administration Cc:



Lots of plugins are creating their own tables but they don't delete them when the plugin is deleted or deactivated.

Is a way exists (maybe with Healthsite) to check on deactivation if a


exists and if so, if the register_deactivation_hook() is used...

If not used, surely tables are not deleted so => notices

Change History (5)

#2 @subrataemfluence
3 years ago

I have a related question. If a plugin is deleted, any table created by it should also be deleted, which is reasonable. But I think deactivating a plugin should keep a table (if created by it) intact with its data because the same plugin could be activated later on. If table is removed when deactivated, all data in it will be lost. However, this is kind of off topic since this depends on the plugin builders how they see it.

Now, regarding displaying notice, if a plugin is removed completely what is the options left for the core to determine that it was removed but table created by it wasn't if there was no signature of this plugin is left somewhere?

Taking both these use cases into consideration the situations are:

  1. Plugin deactivated, but ideally a table created by it should not be removed, so notice doesn't have much of an impact.
  1. Plugin is removed from the system means WordPress doesn't know anymore that there was a plugin which created a table. So, only displaying notice doesn't make any difference here as well. The only option however, as I see, is to check if there are only bundled / shipped plugins are present and there is/are additional tables exist in the database other than that those created by WordPress installation itself.

The bottom line is, is it really a task of WordPress core to do this stuff or it is the responsibility of the plugin developers to clean up tables like this?

Please correct me if I have not understood the underlying issue properly.

#3 @sebastienserre
2 years ago

  • Focuses administration added
  • Keywords needs-patch dev-feedback added

#4 @stuffradio
15 months ago

@sebastienserre I don't think developers should be forced to delete custom tables they create with the plugin. What if someone wants to have a plugin de-activated or deleted but still keep their data in the future? For example if someone has a contact form installed with a bunch of submissions, maybe they want to keep those in the future.

The only thing I could agree with that might be a good idea is to have the capability to list all the custom tables, and maybe have a page in the administration panel list which plugin created them and allow someone to remove those.

#5 @sebastienserre
15 months ago

As a best practices, AMHA Plugin developers should ask if user want to keep their data on deletion.
I think we have something to do to reduce database size of a WordPress install. No need to store and keep alive a Datacenter for unused data.

Note: See TracTickets for help on using tickets.