[wp-trac] [WordPress Trac] #58763: Inconsistent add/get/update/delete_post_meta() functions leads to deleting post metadata.
WordPress Trac
noreply at wordpress.org
Sat Jul 8 09:48:05 UTC 2023
#58763: Inconsistent add/get/update/delete_post_meta() functions leads to deleting
post metadata.
--------------------------+-----------------------------
Reporter: jsmoriss | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: major | Keywords:
Focuses: |
--------------------------+-----------------------------
The add_post_meta(), delete_post_meta(), and update_post_meta() functions
all use wp_is_post_revision() to add/delete/update the metadata of the
post, not its revision. That's fine, but the get_post_meta() function does
NOT use wp_is_post_revision().
As a consequence, if you use get_post_meta() and update_post_meta() during
the saving process for a revision, the post metadata ends up being
overwritten/deleted: The get_post_meta() function gets the **revision**
metadata, and then the update_post_meta() function updates the **post**
metadata, NOT the revision metadata.
js.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58763>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list