Make WordPress Core


Ignore:
Timestamp:
07/10/2020 03:12:00 PM (4 years ago)
Author:
adamsilverstein
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r48352 r48422  
    14381438    $publish_callback_args = array( '__back_compat_meta_box' => true );
    14391439    if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
    1440         $revisions = wp_get_post_revisions( $post->ID );
     1440        $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
    14411441
    14421442        // We should aim to show the revisions meta box only when there are revisions.
     
    14451445            $publish_callback_args = array(
    14461446                'revisions_count'        => count( $revisions ),
    1447                 'revision_id'            => key( $revisions ),
     1447                'revision_id'            => array_shift( $revisions ),
    14481448                '__back_compat_meta_box' => true,
    14491449            );
Note: See TracChangeset for help on using the changeset viewer.