-
Notifications
You must be signed in to change notification settings - Fork 800
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
Jetpack_Media: Delete revision history items before updating metadata #14340
Conversation
…nt metadata Fixes Issue # 14315 When a media file is remotely edited, the Jetpack_Media::edit_media_file() method is called. Within this method, the wp_generate_attachment_metadata() function is called. Then the Jetpack_Media::limit_revision_history() method is called, which determines if the revision history limit has been reached. If the revision history limit has been reached, the Jetpack_Media::delete_media_history_file() method is called. This method calls wp_generated_attachment_metadata(), which overwrites the attachment metadata that was just updated with the attachment metadata of the revision that is about to be deleted. This results in broken image URLs in the wp-admin media library. To fix this, call Jetpack_Media::limit_revision_history() before calling wp_generate_attachment_metadata() in the Jetpack_Media::edit_media_file() method. This will prevent the updated attachment metadata from being overwritten. Finally, fix some PHPCS warnings for comments and whitespace.
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: February 11, 2020. |
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.
Works great, the thumbnail no longer disappears after a couple of edits.
* [not verified] Remove empty readme section * Initial changelog for 8.2 * Changelog: add #14220 * Changelog: add #14252 * Changelog: add #14291 * Changelog: add #14309 * Changelog: add #14304 * Changelog: add general connection log. * Changelog: add #14275 * Changelog: add #14313 * Changelog: add #14213 * Changelog: add #14357 * Add sync testing instructions * Add 8.1.1 changelog back See eeaafab and 61757eb * Changelog: add #14371 * Changelog: add #14386 * Changelog: add #14471 * Changelog: add #14325 * Changelog: add #14194 * Changelog: add #14340 * Changelog: add #14418 * Changelog: add #14417 * Changelog: add #14075 * Changelog: add #14467 * Changelog: add #14307 * Changelog: add #14326
When a media file is remotely edited, the
Jetpack_Media::edit_media_file()
method is called. Within this method, thewp_generate_attachment_metadata()
function is called, which updates the metadata for the updated file. ThenJetpack_Media::limit_revision_history()
is called, which determines if the revision history limit has been reached.If the revision history limit has been reached, the
Jetpack_Media::delete_media_history_file()
method is called. This method calls
wp_generated_attachment_metadata()
on the file that is being deleted, which updates the attachment metadata. However, we already updated the attachment metadata, and this overwrites that updated metadata with the metadata for the file that's being deleted. This causes broken image URLs in the wp-admin media library.Fixes #14315
Changes proposed in this Pull Request:
Jetpack_Media::limit_revision_history()
before callingwp_generate_attachment_metadata()
in theJetpack_Media::edit_media_file()
method. This will prevent the updated attachment metadata from being overwritten.Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions
Test site
Test instructions
Proposed changelog entry for your changes: