Ticket #34560: 34560.15.diff
File 34560.15.diff, 2.7 KB (added by , 4 years ago) |
---|
-
wp-admin/includes/meta-boxes.php
1386 1386 1387 1387 $publish_callback_args = array( '__back_compat_meta_box' => true ); 1388 1388 if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { 1389 $revisions = wp_get_post_revisions( $post->ID );1389 $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) ); 1390 1390 1391 1391 // We should aim to show the revisions meta box only when there are revisions. 1392 1392 if ( count( $revisions ) > 1 ) { … … 1393 1393 reset( $revisions ); // Reset pointer for key() 1394 1394 $publish_callback_args = array( 1395 1395 'revisions_count' => count( $revisions ), 1396 'revision_id' => key( $revisions ),1396 'revision_id' => array_shift( $revisions ), 1397 1397 '__back_compat_meta_box' => true, 1398 1398 ); 1399 1399 add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -
wp-includes/revision.php
219 219 /** 220 220 * Retrieve the autosaved data of the specified post. 221 221 * 222 * Returns a postobject containing the information that was autosaved for the222 * Returns an object containing the information that was autosaved for the 223 223 * specified post. If the optional $user_id is passed, returns the autosave for that user 224 224 * otherwise returns the latest autosave. 225 225 * … … 230 230 * @return WP_Post|false The autosaved data or false on failure or when no autosave exists. 231 231 */ 232 232 function wp_get_post_autosave( $post_id, $user_id = 0 ) { 233 $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) );233 global $wpdb; 234 234 235 foreach ( $revisions as $revision ) { 236 if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { 237 if ( $user_id && $user_id != $revision->post_author ) { 238 continue; 239 } 235 $autosave_name = $post_id . '-autosave-v1'; 236 $user_id_query = ( 0 !== $user_id ) ? "AND post_author = $user_id" : null; 240 237 241 return $revision; 242 } 238 // Construct the autosave query 239 $autosave_query = " 240 SELECT * 241 FROM $wpdb->posts 242 WHERE post_parent = %d 243 AND post_type = 'revision' 244 AND post_status = 'inherit' 245 AND post_name = %s " . $user_id_query . " 246 ORDER BY post_date DESC 247 LIMIT 1"; 248 249 $autosave = $wpdb->get_results( 250 $wpdb->prepare( 251 $autosave_query, 252 $post_id, 253 $autosave_name 254 ) 255 ); 256 257 if ( ! $autosave ) { 258 return false; 243 259 } 244 260 245 return false;261 return $autosave[0]; 246 262 } 247 263 248 264 /**