Allow DROP TABLE schema change in uninstall.php

Open
#2,359 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Start by locating the implementation and tests for the WordPress.DB.DirectDatabaseQuery.SchemaChange sniff. Check how the rules identify database queries and whether the uninstall.php filename is available there. Done means DROP TABLE queries in _uninstall.php no longer produce this warning, while other schema changes remain covered.

Written by the indexing model from the issue text.

Description

Type: Question

Plugins often require their own tables - therefore those tables naturally should be removed during the uninstall process of the plugin. This brings the requirement to execute a query like DROP TABLE IF EXISTS wp_my_table; which is placed in the uninstall.php file.

Currently, the CodeSniffer creates warnings for those database queries, like:

Attempting a database schema change is discouraged. (WordPress.DB.DirectDatabaseQuery.SchemaChange)

Since deleting unnecessary data during the uninstall process is a proper way to avoid leaving trash behind, I suggest to add an exception which allows the DROP TABLE query within the uninstall.php file.

Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/WordPress-Coding-Standards

All issues in WordPress/WordPress-Coding-Standards

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.