Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Delete all customize-draft posts that are referenced by a given changeset post that is deleted #329

Closed
westonruter opened this issue Dec 11, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@westonruter
Copy link
Contributor

When we save a changeset (snapshot) as a draft, we go through and transition any related auto-draft-status posts to customize-draft. This is to prevent the posts referenced in the changeset from erroneously garbage-collected when the changeset itself is persistent. However, what we're not accounting for is the case when the changeset itself is deleted without ever having been published. What we're not doing is deleting all of these related customize-draft-status posts and so they are going to be sticking around forever, orphaned from any changeset.

@PatelUtkarsh
Copy link
Member

In orphan logic, we need to make sure we check for a fork and merge snapshot and don't delete the post in that case.

@westonruter
Copy link
Contributor Author

I think we could potentially eliminate the separate customize-draft status by instead making use of a far-future post_date for the auto-draft posts.

See #39715: Customize: Keep alive auto-drafts created for page/post stubs, and delete when changeset is garbage-collected

There is a proof of concept for nav_menus_created_posts: https://core.trac.wordpress.org/attachment/ticket/39715/proof-of-concept.php

Note that this doesn't address the problem of forks.

@PatelUtkarsh PatelUtkarsh self-assigned this Feb 22, 2017
@PatelUtkarsh
Copy link
Member

Should we also delete auto-draft post (Or change its date to clean up) in the case of a changeset is trashed?

How should we go about this @westonruter using auto-draft or keep using customize-draft?

@westonruter
Copy link
Contributor Author

@PatelUtkarsh isn't this already accounted for by delete_changeset_nav_menus_created_auto_draft_posts in the proof of concept? It skips rolling back the post_date of related auto-draft posts upon trashing by instead just waiting to delete the posts until the changeset is deleted entirely.

And yes, using this technique of setting the post_date for auto-draft posts far into into future will allow us to eliminate the separate customize-draft status entirely.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants