Support non-unique meta key in autosave #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
#60
Solution
Pete mention in #24 that a filter to modify the metadata from the
$_POST
variable.I looked at the PR #25 but soon realised this would not be a solution for this problem as
add_metadata()
needs to called multiple times for each non-unique meta data.In addition there is a check if the data has been changed.
get_post_meta()
is setup to get only a single value, the first value which does not work for non-unique meta values.wp-post-meta-revisions/wp-post-meta-revisions.php
Line 88 in ca45992
In WP 4.9.8
register_post_meta()
was introduced. This allows developers to register meta key as non-unique and allows us to use the data to save the data correctly. This is how I have done it in the test:I have added tests for autosaving both unique and non-unique meta data.