-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix fatal error on revisions with post meta of type array #10560
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
Conversation
|
Hi @LAPSrj! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Co-authored-by: Weston Ruter <[email protected]>
* trunk: (44 commits) I18N: Use `wp_get_list_item_separator()` as list separator for the states of sites, posts, and media. Tests: Use `assertSame()` in some newly introduced tests. Export: Update `export_wp()` to handle `get_comment()` returning `null` due to filter. I18N: Add missing translation functions for REST API app login. Tests: Use `assertSame()` in some newly introduced tests. Networks and Sites: Ensure the Site Address field renders in correct order when RTL locale is active. Tests: Use `assertSame()` in some newly introduced tests. Add: Unit test to validate core abilities schemas only include valid properties. Docs: Improve specificity of types in `WP_Script_Modules` and `script-modules.php` functions. I18N: add border.radiusSizes key to theme-i18n.json Posts, Post Types: Only set default title for custom post types if they have title support. Site Health: Include value of `EMPTY_TRASH_DAYS` constant in debug data. Docs: Improve accuracy for types in phpdoc for `WP_Dependencies`, `_WP_Dependency`, `WP_Scripts`, and `WP_Styles`. Script Loader: Re-target release for missing dependency notices from 7.0.0 to 6.9.1. Docs: Add missing parameter descriptions in `wp-admin/install.php`. Site Health: Add common HTTP response headers for page cache detection. Docs: Update `@since x.y.z` with actual version number. Plugins: Restore line break between the filter links row and the plugin cards in the Featured view. Mail: Add missing `embeds` key for the `wp_mail_succeeded` action's `$mail_data` param. Upgrade/Install: Add missing file to the `$_old_files` array. ...
|
Gemini's review of all the changes, including the new test: Here's my review of the changes: Changes in The core change is the introduction of --- a/src/wp-includes/revision.php
+++ b/src/wp-includes/revision.php
@@ -187,7 +187,7 @@ function wp_save_post_revision( $post_id ) {
$post_has_changed = false;
foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
- if ( normalize_whitespace( $post->$field ) !== normalize_whitespace( $latest_revision->$field ) ) {
+ if ( normalize_whitespace( maybe_serialize( $post->$field ) ) !== normalize_whitespace( maybe_serialize( $latest_revision->$field ) ) ) {
$post_has_changed = true;
break;
}
Changes in A new test method
Conclusion: Both the code change in The overall quality of the proposed changes is high. |
…with revisioned non-scalar post meta. Developed in #10560 Follow-up to [56714]. Props LAPSrj, manhphucofficial, westonruter. See #20299. Fixes #64314. git-svn-id: https://develop.svn.wordpress.org/trunk@61372 602fd350-edb4-49c9-b593-d223f7449a82
…with revisioned non-scalar post meta. Developed in WordPress/wordpress-develop#10560 Follow-up to [56714]. Props LAPSrj, manhphucofficial, westonruter. See #20299. Fixes #64314. Built from https://develop.svn.wordpress.org/trunk@61372 git-svn-id: http://core.svn.wordpress.org/trunk@60684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…with revisioned non-scalar post meta. Developed in WordPress/wordpress-develop#10560 Follow-up to [56714]. Props LAPSrj, manhphucofficial, westonruter. See #20299. Fixes #64314. Built from https://develop.svn.wordpress.org/trunk@61372 git-svn-id: https://core.svn.wordpress.org/trunk@60684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This is my proposed fix for ticket 64314, where a fatal error happens when trying to save a post if you have enabled revision for a post meta that is an array.
In this proposed fix I'm using
serializeto make any type of variable a string. I've chosen that because:Trac ticket: 64314
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Drafted Commit Message