-
Notifications
You must be signed in to change notification settings - Fork 156
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 featured image delete push issue #310
Conversation
Meta deletion is broadly a problem, see #284. Happy to keep this PR open and milestone it if media should be handled separately though, I haven't dug into the code to find out. |
So we do handle media and meta separately at the moment (as far as processing and setting), so I think we will probably handle the deletion separately as well. That said, in my mind it makes sense to deal with deletion as one larger task, so we keep in mind all scenarios when implementing this. I'm not opposed to the approach in this PR but a couple things come to my mind:
|
This feels dangerous: what if the images themselves had been used in another post on the destination site? |
Doesn't seem like we're quite at a consensus about approach/result yet, punting pending further dedicated discussion. |
First, let's separate the terms My feeling on this is that we could limit this PR to the following use case: For all other cases, we can cover them via a separate PR in a future release that more fully handles meta and other media removals/deletions. |
Side note: I think it will be good to blacklist For deletion we developed our solution, which is based on I'm not sure if this approach is acceptable or not, but you can find our solution here https://github.com/NovemBit/distributor/blob/develop/includes/utils.php ( I know that it needs improvements before PR) I think this behavior is safe as long as |
As this PR still needs discussion and we're working to clear the milestone to get nearer a release, I'm going to punt this to the next release in hopes we can get through our discussion and to an agreed approach by then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me and worked while testing with:
- internal push
- internal pull
- external push
- external pull
It looks like the set_media()
utility function was intended to handle this situation but the empty()
check means the relevant code doesn't run:
distributor/includes/utils.php
Lines 790 to 792 in f769e29
if ( ! $found_featured_image ) { | |
delete_post_meta( $post_id, '_thumbnail_id' ); | |
} |
I've put in a couple of coding style nitpicks but otherwise consider this PR as approved. ✅
This PR is on the 2.1.0 milestone so I'm going to hold of clicking the approve button for now so I don't accidentally merge it prior to the release of 2.0.0 in the coming weeks.
Co-authored-by: Peter Wilson <[email protected]>
Co-authored-by: Peter Wilson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hitting the approve button and merging now that 2.0.0 is released.
This has been added to the milestone for 2.0.1 so should be in the next release.
If we delete the featured image for a post, it does not delete for the distributed post. This happens only if the featured image is selected from Media Library, works fine if the featured image is uploaded to the actual post.
Steps to reproduce:
This PR contains an
else
statement to delete featured image ifdistributor_media
is empty. There are still other places (NetworkSiteConnection.php) which would need a similar condition, I am happy to add those as well if this approach looks good to you.