mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Revisions: optimize performance when post has large number of revisions.
Improve speed and reduce the memory footprint when loading posts with many revisions. * Use a direct query in `wp_get_post_autosave` to avoid loading all revisions. * Query for IDs vs full objects in `register_and_do_post_meta_boxes`. Props pdfernhout, johnnyb, miqrogroove, ocean90, senatorman, DBrumbaugh10Up, martijn-van-der-kooij, pavelevap, mackensen, mikeyarce, whyisjake. Fixes #34560. git-svn-id: https://develop.svn.wordpress.org/trunk@48422 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1437,14 +1437,14 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||
|
||||
$publish_callback_args = array( '__back_compat_meta_box' => true );
|
||||
if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
|
||||
$revisions = wp_get_post_revisions( $post->ID );
|
||||
$revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
|
||||
|
||||
// We should aim to show the revisions meta box only when there are revisions.
|
||||
if ( count( $revisions ) > 1 ) {
|
||||
reset( $revisions ); // Reset pointer for key().
|
||||
$publish_callback_args = array(
|
||||
'revisions_count' => count( $revisions ),
|
||||
'revision_id' => key( $revisions ),
|
||||
'revision_id' => array_shift( $revisions ),
|
||||
'__back_compat_meta_box' => true,
|
||||
);
|
||||
add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
|
||||
|
||||
Reference in New Issue
Block a user