Popup-Maker icon indicating copy to clipboard operation
Popup-Maker copied to clipboard

Delete revisions on uninstall

Open fpcorso opened this issue 4 years ago • 4 comments

Right now, when the Popup Maker is deactivated (with the complete_uninstall option enabled), we delete all popups, popup themes, all post meta where meta_key LIKE 'popup_%', popup taxonomies, and all our options.

However, our SQL for deleting popups seems to leave behind revisions. If you run the complete uninstall, everything will be deleted as intended. However, if you look through the posts table in the DB, you see parent-less revisions of the popups. After completely uninstalling, I still had dozens of parent-less revisions: image

Would we have a way to ensure these revisions with a post status of "inherit" get deleted too?

Here is the line for deleting popups and popup themes: https://github.com/PopupMaker/Popup-Maker/blob/master/classes/Install.php#L139

fpcorso avatar Jun 11 '20 16:06 fpcorso

@fpcorso Hmm, I think a normal db cleanup routine would clear those away. Never realized WP would leave them behind, but I guess we are not calling wp_delete_post but rather deleting directly from DB.

Could probably change the post_type we delete to be IN ( 'popup', 'inherit', 'revision' ).

Or we could simplify and get list of IDs, then pass them all through a WP core function to delete them with all the bells and whistles.

danieliser avatar Jun 11 '20 18:06 danieliser

@danieliser Right now, we only run two SQL queries which are really efficient. Would loading 100 popup ID's and running them through wp_delete_post individually be efficient enough to not fail?

The only place in the query we specify only our content is within the IN() part so adding revision there might delete all site revisions and not just popup-related ones. I'll have to test that.

fpcorso avatar Aug 06 '20 15:08 fpcorso

@fpcorso no it wouldn't be efficient.

Also don't think we should spend a ton of time optimizing for this. Many hosts disable revisions, many tools already clean them. Unless we use wp_delete_post, we could be potentially deleting revisions that are not related to our plugin as well.

danieliser avatar Aug 06 '20 19:08 danieliser

@danieliser I'll punt this one for now. I want to see if I can get some data on how many sites might have revisions enabled and aren't using any optimization/cleaning tool.

fpcorso avatar Aug 06 '20 19:08 fpcorso