Revisions: slash meta values for autosave (preview) revisions.

Correct an issue where meta values containing characters like quote `”` could not be previewed on published posts. The function `update_metadata` expects data to be slashed.

Also, add a test to confirm that storing JSON data which requires slashing in autosave meta works as expected, and improve naming for a data provider added in [56714].

Follow up to [56714].

Props mukesh27, spacedmonkey.
Fixes #20564.


Built from https://develop.svn.wordpress.org/trunk@56745


git-svn-id: http://core.svn.wordpress.org/trunk@56257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2023-09-29 15:07:26 +00:00
parent d922a9e96a
commit 472f1ec59d
2 changed files with 2 additions and 2 deletions

View File

@ -421,7 +421,7 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller {
if ( ! empty( $meta ) ) {
foreach ( $revisioned_meta_keys as $meta_key ) {
if ( isset( $meta[ $meta_key ] ) ) {
update_metadata( 'post', $revision_id, $meta_key, $meta[ $meta_key ] );
update_metadata( 'post', $revision_id, $meta_key, wp_slash( $meta[ $meta_key ] ) );
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-beta1-56744';
$wp_version = '6.4-beta1-56745';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.