From d68c59661ee9d95f4402a5472bf9d4440e5a85e4 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sun, 10 Sep 2023 22:37:06 -0600 Subject: [PATCH] Fix overwriting of published post meta when previewing footnote changes --- packages/block-library/src/footnotes/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/footnotes/index.php b/packages/block-library/src/footnotes/index.php index 5924db3a190c2..184bff2da9578 100644 --- a/packages/block-library/src/footnotes/index.php +++ b/packages/block-library/src/footnotes/index.php @@ -242,7 +242,8 @@ function _wp_rest_api_autosave_meta( $autosave ) { return; } - update_post_meta( $id, 'footnotes', wp_slash( $body['meta']['footnotes'] ) ); + // Can't use update_post_meta() because it doesn't allow revisions. + update_metadata( 'post', $id, 'footnotes', wp_slash( $body['meta']['footnotes'] ) ); } // See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L391C1-L391C1. add_action( 'wp_creating_autosave', '_wp_rest_api_autosave_meta' );