Ticket #20564: 20564.6.diff
File 20564.6.diff, 3.8 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/post.php
1280 1280 $new_autosave['post_author'] = $post_author; 1281 1281 1282 1282 // Auto-save revisioned meta fields too. 1283 foreach ( _wp_post_revision_meta_keys() as $meta_key ) {1284 if ( ! isset( $_POST[ $meta_key ] ))1285 continue;1283 $revision_meta = array(); 1284 foreach ( _wp_post_revision_meta_keys() as $meta_key ) 1285 $revision_meta[ $meta_key ] = $_POST[ $meta_key ]; 1286 1286 1287 // Use the underlying delete_metadata and add_metadata vs delete_post_meta 1288 // and add_post_meta to make sure we're working with the actual revision meta. 1289 delete_metadata( 'post', $new_autosave['ID'], $meta_key ); 1290 add_metadata( 'post', $new_autosave['ID'], $meta_key, $_POST[ $meta_key ] ); 1291 } 1287 // Use the underlying update_metadata vs update_post_meta to make sure 1288 // metadata is added to the revision post and not its parent. 1289 if ( ! empty( $revision_meta ) ) 1290 update_metadata( 'post', $new_autosave['ID'], '_revision_meta', $revision_meta ); 1292 1291 1293 1292 return wp_update_post( $new_autosave ); 1294 1293 } -
wp-includes/revision.php
133 133 } 134 134 135 135 // Check whether revisioned meta fields have changed. 136 $revision_meta = (array) get_post_meta( $last_revision->ID, '_revision_meta', true ); 136 137 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 137 if ( get_post_meta( $post->ID, $meta_key ) != get_post_meta( $last_revision->ID, $meta_key )) {138 if ( isset( $revision_meta[ $meta_key ] ) && get_post_meta( $post->ID, $meta_key ) != $revision_meta[ $meta_key ] ) { 138 139 $post_has_changed = true; 139 140 break; 140 141 } … … 279 280 do_action( '_wp_put_post_revision', $revision_id ); 280 281 281 282 // Save revisioned meta fields. 282 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 283 $meta_values = get_post_meta( $post_id, $meta_key ); 284 if ( false === $meta_values ) 285 continue; 283 $revision_meta = array(); 284 foreach ( _wp_post_revision_meta_keys() as $meta_key ) 285 $revision_meta[ $meta_key ] = get_post_meta( $post_id, $meta_key ); 286 286 287 // Use the underlying add_metadata vs add_post_meta to make sure 288 // metadata is added to the revision post and not its parent. 289 foreach ( $meta_values as $meta_value ) 290 add_metadata( 'post', $revision_id, $meta_key, $meta_value ); 291 } 287 // Use the underlying update_metadata vs update_post_meta to make sure 288 // metadata is added to the revision post and not its parent. 289 if ( ! empty( $revision_meta ) ) 290 update_metadata( 'post', $revision_id, '_revision_meta', $revision_meta ); 292 291 293 292 return $revision_id; 294 293 } … … 365 364 $update = wp_slash( $update ); //since data is from db 366 365 367 366 // Restore revisioned meta fields. 367 $revision_meta = (array) get_post_meta( $revision['ID'], '_revision_meta', true ); 368 368 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 369 369 delete_post_meta( $update['ID'], $meta_key ); 370 $meta_values = get_post_meta( $revision['ID'], $meta_key ); 371 if ( false === $meta_values)370 371 if ( ! isset( $revision_meta[ $meta_key ] ) ) 372 372 continue; 373 373 374 foreach ( $ meta_valuesas $meta_value )374 foreach ( $revision_meta[ $meta_key ] as $meta_value ) 375 375 add_post_meta( $update['ID'], $meta_key, $meta_value ); 376 376 } 377 377 … … 538 538 if ( ! is_object( $preview ) ) 539 539 return $value; 540 540 541 return get_post_meta( $preview->ID, $meta_key, $single ); 541 $revision_meta = (array) get_post_meta( $preview->ID, '_revision_meta', true ); 542 if ( isset( $revision_meta[ $meta_key ] ) ) 543 return $revision_meta[ $meta_key ]; 544 545 return ''; 542 546 } 543 547 544 548 function _wp_get_post_revision_version( $revision ) {