Commit dd8b08a49b for wordpress.org
commit dd8b08a49b359caf31830d1452772fa561458dd4
Author: adamsilverstein <adamsilverstein@git.wordpress.org>
Date: Fri Dec 4 18:08:01 2026 +0000
Docs: Explain how `get_post_meta()` handles revision IDs.
`add_post_meta()`, `update_post_meta()` and `delete_post_meta()` act on the parent post when passed a revision ID, while `get_post_meta()` reads the meta stored on the revision itself. Code that reads with one and writes with the others during a revision save can overwrite the parent post's meta with an empty value.
Pointing `get_post_meta()` at the parent post was considered, but since 6.4 revisions store their own meta for keys registered with `revisions_enabled`, and core reads it with `get_post_meta( $revision_id )` when restoring a revision and when checking for meta-only changes. Document the difference in the `get_post_meta()` docblock instead, so behavior is unchanged.
Props mhshujon, felipeelia, jsmoriss, sirlouen, sandeepdahiya, oglekler, nicolefurlan, hellofromtonya.
Fixes #58763.
Built from https://develop.svn.wordpress.org/trunk@65924
git-svn-id: http://core.svn.wordpress.org/trunk@64953 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 6d42c97836..4ce3b2a0ff 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -2783,6 +2783,14 @@ function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
/**
* Retrieves a post meta field for the given post ID.
*
+ * When given a revision ID, this reads the meta stored on the revision itself,
+ * unlike add_post_meta(), update_post_meta() and delete_post_meta(), which act
+ * on the revision's parent post. Revisions only store meta for the keys returned
+ * by wp_post_revision_meta_keys(), such as those registered with `revisions_enabled`.
+ *
+ * To read the parent post's meta, pass the ID returned by wp_is_post_revision().
+ * To write meta to a revision, use add_metadata() or update_metadata() directly.
+ *
* @since 1.5.0
*
* @param int $post_id Post ID.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 0364670a5c..63302f432c 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65923';
+$wp_version = '7.3-alpha-65924';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.