-
Notifications
You must be signed in to change notification settings - Fork 841
Jetpack Sync: Only send a single updated_post_meta action per attachment metadata request. #45921
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
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.
Nice work, Karen!
I wonder if we can do even better here and also ensure we don't add those meta to Sync's queue in the first place.
The logic could be similar to #45697, aka:
- Only add a single
updated_post_metaactions to Sync's queue perpost_idper request. We can add this logic infilter_meta - ensure we fetch the fresh meta before sending via
wp_get_attachment_metadatainfilter_updated_post_meta_before_send. Pretty much what you already do but without the static logic indrop_stale_attachment_metadata
What do you think?
|
Thanks for looking at this! I couldn't follow exactly the same approach as with the mentioned PR due to filter interdependencies (eg. with New changes:
I've not made changes in I have added send-time changes for Before, we only refreshed Now, we dedupe The fix is to refresh As for the duplication between the filters, theres no helper for the duplicated logic because sharing a single helper caused timing regressions. Keeping the wrappers separate isolates per-hook behavior. |
fgiannar
left a comment
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.
Looks and tests well 👍
Fixes SYNC-166
Prevent
updated_post_metafrom running multiple times in a single request if the meta key is_wp_attachment_metadataand ensure we send only the final attachment data.Proposed changes:
update_post_metaaction is firing multiple times during one media update (in the case of_wp_attachment_metadata, as it is written incrementally during processing of the attachment), but we know the final order state will be reliable to fetch at send time.We are only doing this for the
_wp_attachment_metadatapost meta at this stage. This could be expanded to include other particularly noisy metas but could be costly if expanded to all (lots of unnecessary DB reading for example).Other information:
Jetpack product discussion
SYNC-166
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
To test this out, on a self-hosted site connected to Jetpack, or WoA site, with the Jetpack beta tester plugin installed and this branch applied
/wp-admin/upload.php, and upload a media item to the library.updated_post_metafor the upload with the namewp_attachment_metadata(another should exist too but it is for the_wp_attached_filemeta key).postmetatable in the DB for your site, inspect hewp_attachment_metadatacalue for the newly uploaded image.wpsh, runninggpr select meta_value from wp_YOURBLOGID_postmeta where post_id=YOURMEDIAID and meta_key='_wp_attachment_metadata'. You may need to runcl 3000` first so that the serialized value is not truncated.Other tests to confirm no issues:
wp_get_attachment_metadatain a code snippet, the new info should be there on the remote site and cache site. Here's a snippet you can add via a code snippets plugin (and to run it, try cropping an existing image): 3999d-pb