-
Notifications
You must be signed in to change notification settings - Fork 805
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
VideoPress: Fix VideoPress Attachment Deletions on wp.com #20832
Conversation
…video on wp.com.
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
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.
Tested perfectly for the happy path, but when I tried to make things break it got into some funny situations.
I wonder if we check for specific errors, like 404
and allow the function to return null
. This could help if the video was deleted on wpcom but the request timed out (or jetpack lost connection). The next time the user tries to delete the video we'd block them because its an error, but really if the video is gone from the server we can allow it to be removed from their site's media library.
|
||
$guid = get_post_meta( $post->ID, 'videopress_guid', true ); | ||
if ( empty( $guid ) ) { | ||
return false; |
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.
I wonder if this should return null
too? If its a videopress video but the guid is missing, there is probably nothing anyone can do to help remove this, and/or it may have never finished uploading or transcoding.
Not 100% sure about this though. I suppose we could manually remove it based on blog id and post it, so maybe failing here is OK. OR, maybe our endpoint can optionally take blog id / post id somehow as a fallback so guid isn't actually required? Not sure how likely guid missing from here would be though.
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.
I think that should be ok to return null
here. I think the chance of this happening is very small so it may be best to just delete it to avoid confusion. I'll update it!
I like this idea, at least for |
…check as well to allow the video to be deleted. Also cleaned up some linter errors.
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.
404
check works as expected!
Other than the latest doc block warning, everything looks good!
c13265a
to
fff5d41
Compare
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 seems to test well for me. I was wondering if we should take that opportunity to also delete the poster image or images that were created for that video?
That's a good call - I assumed all of the thumbnails were stored on wp.com but I see some in the local media library. |
…, if it exists it deletes it.
Ok the attachment poster image is also deleted now as well: 5d5713e. Updated the testing instructions on how to test for that. |
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 seems to test well for me. 👍
* master: tools: Tool to report unreleased projects (#20874) Add max length for stacktrace in Slack notifications (#20913) Show HLS Playlist for the VideoPress video url, instead of fragmented mp4 file (#20839) VideoPress: Fix VideoPress Attachment Deletions on wp.com (#20832) Update various JS dependencies (#20890) Widget Visibility: add scaffolding for upcoming editor features. (#20910) Heartbeat: Fix typo (#20901) Social Icons: fix being able to remove icons (#20899) Update To-Test.md for Jetpack 10.1 (#20894) Update dependency size-limit to v5 (#20893) Release: start 10.2 cycle (#20896) Jetpack 10.1 Changelog (#20892) E2E tests: add report name option in Slack notification (#20887) Carousel: add more specific selectors for the carousel cursor (#20882) E2E Tests: Fix pre-connection test (#20888) Search: fix body scroll for overlay open/close (#20733) E2E Tests: Fix mailchimp test (#20855) E2E tests: improve error handling (#20884)
Fixes issue where deleting a VideoPress video would not actually delete the VideoPress entry on wp.com. Uses the
pre_delete_attachment
filter to attempt deletion of VideoPress video on wp.com.There's a big change here in that the attachment will not get deleted unless wp.com successfully deleted the VideoPress video (unless the API returns a
404
which means it was already deleted or not found). This is to prevent any dangling data. One thing I'd like advice on here is how we can tell the user there was an error so they can take appropriate action. At a minimum it'd be great if we could add to the activity log so that happiness can help troubleshoot.Changes proposed in this Pull Request:
Jetpack product discussion
pxWta-Zz-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions:
guid
.Also test that attachment poster image is deleted:
* Delete the video * Try to access the thumbnail url, it should also be deleted.