-
Notifications
You must be signed in to change notification settings - Fork 843
Sync: prevent deprecation warning with null values in trim_post_meta #43149
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
Sync: prevent deprecation warning with null values in trim_post_meta #43149
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 SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
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.
Many thanks for the fix, Karen! LGTM 🚢
Fixes VULCAN-56
Proposed changes:
strlen, intrim_post_meta. This prevents a PHP deprecation warning when the serialized value passed intostrlenis null:strlen(returning a value of 0), therefore setting the meta_value to ''. We still want that to be the case - if$serialized_valueis null, then set$meta_valueto 'null'. By explicitly checking this first, we prevent the PHP deprecation warning as we don't run null throughstrlen, and we get the same results as before so as not to break any expected functionality.Other information:
Jetpack product discussion
n/a
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
To replicate this issue, test with trunk locally or on bleeding edge / release candidate / latest version of Jetpack on a Jurassic Ninja site using the Jetpack Beta tester plugin. Then:
class-posts.php, just above the changed line, set$serialized_valueto null (on a site using the Jetpack Beta tester plugin you'll be looking forplugins/jetpack-dev/jetpack_vendor/automattic/jetpack-sync/src/modules/class-posts/php)To test the fix, follow the same steps after applying the changes in this PR. You should not see the deprecation warning in your error logs.