Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Uninstall distributor #540

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open

Fix: Uninstall distributor #540

wants to merge 35 commits into from

Conversation

dinhtungdu
Copy link
Contributor

@dinhtungdu dinhtungdu commented Mar 10, 2020

Description of the Change

  • Add uninstall.php script to delete distributor data in the database.
  • Add DT_REMOVE_ALL_DATA constant to prevent accidental data deletion.

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

@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
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
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 iamdharmesh and a team August 4, 2023 12:49
@ravinderk
Copy link
Contributor

@peterwilsoncc Distributor supports multisite. In this case, the Super Admin can only delete the plugin. I think we should clear distributor plugin data from subsites, what does this think?

cc: @jeffpaul

@jeffpaul
Copy link
Member

@ravinderk so you're asking about the case where distributor is network installed and network activated (different from the case where it's installed or activated on individual sites for a use case where someone only wants distributor to work on parts of a multi site)?

@ravinderk
Copy link
Contributor

@ravinderk so you're asking about the case where distributor is network installed and network activated (different from the case where it's installed or activated on individual sites for a use case where someone only wants distributor to work on parts of a multi site)?

@jeffpaul You are correct.

@jeffpaul
Copy link
Member

I'm not quite wildly in favor of deleting Distributor syndication mapping post meta when someone deactivates the plugin, though I suppose if someone actually uninstalls (again, specifically considering this differently from deactivating) it's probably fine to clear Distributor data. The downside is someone who then wants to re-install and activate Distributor that all previous syndication mappings would be gone and make things super difficult to get synchronized again, but that would fall into a _doing_it_wrong() scenario.

@ravinderk want to work on iterating on the PR here to properly remove Distributor data when someone uninstalls the plugin (again, NOT when its merely deactivated but ONLY when it's uninstalled)?

@ravinderk
Copy link
Contributor

ravinderk commented Sep 8, 2023

I'm not quite wildly in favor of deleting Distributor syndication mapping post meta when someone deactivates the plugin, though I suppose if someone actually uninstalls (again, specifically considering this differently from deactivating), it's probably fine to clear Distributor data. The downside is that for someone who then wants to re-install and activate Distributor, all previous syndication mappings would be gone and make things super difficult to get synchronized again, but that would fall into a _doing_it_wrong() scenario.

@ravinderk wants to work on iterating on the PR here to properly remove Distributor data when someone uninstalls the plugin (again, NOT when it's merely deactivated but ONLY when it's uninstalled)?

@jeffpaul I implemented logic to remove distributor data from the database only if:

  • Admin uninstalling plugin
  • DT_REMOVE_ALL_DATA is set to true (to prevent accidental deletion of data)

I also recommend showing the modal when uninstalling the distributor plugin to inform the admin.

@ravinderk, so you're asking about the case where the distributor is network installed and network activated (different from the case where it's installed or activated on individual sites for a use case where someone only wants the distributor to work on parts of a multi-site)?

Removing distributor data from each subsite can be very resource-intensive. I think we should not do it and inform the admin about this when uninstalling the plugin

@dinhtungdu dinhtungdu removed their assignment Sep 11, 2023
@jeffpaul
Copy link
Member

jeffpaul commented Sep 11, 2023

I also recommend showing the modal when uninstalling the distributor plugin to inform the admin.

Removing distributor data from each subsite can be very resource-intensive. I think we should not do it and inform the admin about this when uninstalling the plugin.

I concur on both points.

@ravinderk
Copy link
Contributor

@jeffpaul I implemented the deactivation modal.

cc: @peterwilsoncc

@jeffpaul jeffpaul removed the request for review from ravinderk January 9, 2024 22:21
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I've added a few notes inline

* wp-config.php. This is to prevent data loss when deleting the plugin from the backend
* and to ensure only the site owner can perform this action.
*/
if ( defined( 'DT_REMOVE_ALL_DATA' ) && true === DT_REMOVE_ALL_DATA ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will only remove the data from the current site (the network base site on the network tab) but the data will remain on sub-sites.

It might be possible to loop through the sites on small networks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@peterwilsoncc, after discussing with @jeffpaul, we decided to take care of the main website. It will be helpful for users to be aware of this.

@jeffpaul Do you have thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think that so long as we've presented the admin uninstalling Distributor with an "are you sure" sort of message on the impacts of fully removing Distributor data, then we should look for a reliable and performant, if slow and long-running, approach to clearing that data across all sites on a network.

uninstall.php Outdated Show resolved Hide resolved
includes/bootstrap.php Show resolved Hide resolved
includes/bootstrap.php Outdated Show resolved Hide resolved
@jeffpaul jeffpaul removed their request for review February 19, 2024 21:07
@jeffpaul
Copy link
Member

Let's follow what WP.org recommends/requires: https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/

@jeffpaul
Copy link
Member

jeffpaul commented Jul 8, 2024

@10up/open-source-practice another PR that would be good to look into getting wrapped up and ready for release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:discussion This requires discussion to determine next steps. type:enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uninstall distributor (completely)
4 participants