Skip to content

Fix: Uninstall distributor#540

Merged
dkotter merged 64 commits into
developfrom
fix/349
Sep 9, 2025
Merged

Fix: Uninstall distributor#540
dkotter merged 64 commits into
developfrom
fix/349

Conversation

@dinhtungdu

@dinhtungdu dinhtungdu commented Mar 10, 2020

Copy link
Copy Markdown
Contributor

Description of the Change

  • Add an uninstall.php script to delete distributor data from the database.
  • Add DT_REMOVE_ALL_DATA constant to prevent accidental data deletion.
  • Deletes entries from the options table.
  • Do not delete posts and meta other than Subscriptions.

A modal will display when deactivating the plugin. This modal does not display in sub-sites.

image

Benefits

Delete distributor data on uninstalling.

Possible Drawbacks

n/a

Verification Process

Check the database manually.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Closes #349

Changelog Entry

Added - Provide way to delete all Distributor data on plugin deletion, utilizing the DT_REMOVE_ALL_DATA constant.

Credits

Props @dinhtungdu, @faisal-alvi, @peterwilsoncc, @ravinderk, @qasumitbagthariya, @jeffpaul, @dkotter

@jeffpaul jeffpaul added this to the 2.0.0 milestone Mar 10, 2020
@jeffpaul jeffpaul added the type:enhancement New feature or request. label Mar 10, 2020
@jeffpaul jeffpaul modified the milestones: 2.0.0, 2.1.0 Mar 26, 2020
@jeffpaul jeffpaul added the needs:discussion This requires discussion to determine next steps. label Mar 26, 2020
@jeffpaul

Copy link
Copy Markdown
Member

Moving this to 2.1.0 as we still need to discuss what items we can/should safely remove during uninstall.

@jeffpaul jeffpaul requested review from a team and iamdharmesh and removed request for a team June 7, 2023 15:59
@ravinderk

Copy link
Copy Markdown
Contributor

@peterwilsoncc, Can you provide a list of data we should remove when someone installs a plugin?

cc: @dkotter @jeffpaul

@ravinderk ravinderk self-assigned this Aug 4, 2023
@ravinderk ravinderk marked this pull request as ready for review August 4, 2023 12:48
@ravinderk ravinderk requested a review from a team as a code owner August 4, 2023 12:48
@ravinderk ravinderk requested review from peterwilsoncc and removed request for a team and iamdharmesh August 4, 2023 12:49
@faisal-alvi

Copy link
Copy Markdown
Contributor

@peterwilsoncc I've added a few commits and included a couple of questions for confirmation. Could you please take a look at #540 (comment) and #540 (comment)?

@faisal-alvi

Copy link
Copy Markdown
Contributor

@peterwilsoncc I’m now retrieving both the option IDs and names. IDs to delete the records, and names to clear the caches.

For multisite, I’m using $network_id: sitemeta.meta_key for cache deletion. Let me know if any adjustments are needed.

@peterwilsoncc peterwilsoncc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good but some odd behaviour when I try to delete the plugin

  • the dist/css file can't be deleted.
  • The database queries on a single site were failing. Not sure why.

To test I've been running the release script and unzipping and activating a duplicate copy to make sure I don't delete the git repo.

Comment thread uninstall.php

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File needs to be added to this block of code

patterns: [
{ from: 'readme.txt', to: './' },
{ from: 'README.md', to: './' },
{ from: 'CHANGELOG.md', to: './' },
{ from: 'composer.json', to: './' },
{ from: 'distributor.php', to: './' },
{ from: '.github/workflows/*', to: './' },
{ from: '.gitattributes', to: './' },
{ from: 'assets/img/*', to: './' },
{ from: 'dist/**/*', to: './' },
{ from: 'includes/**/*', to: './' },
{ from: 'lang/**/*', to: './' },
{ from: 'templates/**/*', to: './' },
{
from: 'vendor/yahnis-elsts/plugin-update-checker/**/*',
to: './',
},
],
} ),

@faisal-alvi

Copy link
Copy Markdown
Contributor

Hey @peterwilsoncc,

I tested again on both a multisite network and a single site, but I didn’t encounter any odd behavior when deleting the plugin.

  • The dist/css files were successfully deleted on my end (see the below GIF).
  • The database queries were functioning properly, and all entries in the options table were being deleted.

all-files-deleted-distributor

I also ran the release script and used the zip to test.

Can you please check again? Or @qasumitbagthariya if you have some time to test this, that would be great.

peterwilsoncc
peterwilsoncc previously approved these changes Dec 2, 2024

@peterwilsoncc peterwilsoncc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@faisal-alvi Looks like it was file permission error between my local and virtual environments. Once I ran chmod it worked as expected.

@jeffpaul

jeffpaul commented Dec 2, 2024

Copy link
Copy Markdown
Member

@qasumitbagthariya over to you for QA

@dkotter dkotter modified the milestones: 2.1.0, 2.2.0 Feb 7, 2025
@dkotter dkotter modified the milestones: 2.2.0, 2.3.0 Aug 26, 2025
@qasumitbagthariya

Copy link
Copy Markdown
Contributor

@faisal-alvi

QA Update ✅


I have verified this PR in the fix/349 branch, which has been fixed and is functioning as intended.

I tested the following on this branch:

  • Distribution de-activate popup ✅
  • Deletes entries from the options table. ✅
  • Do not delete posts and meta other than Subscriptions. ✅
Screen.Recording.2025-09-09.at.3.15.31.PM.mov

Testing Environment

Details
  • WordPress: 6.8.2
  • Theme: Twenty Twenty-Five 1.3
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: fix/349

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for UAT
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

@github-actions github-actions Bot added needs:code-review This requires code review. and removed needs:feedback This requires reporter feedback to better understand the request. labels Sep 9, 2025
@dkotter dkotter merged commit 9b62a55 into develop Sep 9, 2025
20 of 21 checks passed
@dkotter dkotter deleted the fix/349 branch September 9, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review. type:enhancement New feature or request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninstall distributor (completely)

8 participants