WordPress.org

Make WordPress Core

Changeset 48436


Ignore:
Timestamp:
07/11/2020 12:28:07 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Revisions: Replace array_shift() with reset() in register_and_do_post_meta_boxes() for better performance.

Follow-up to [31829], [48422].

See #34560.

File:
1 edited

Legend:

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

    r48422 r48436  
    14371437
    14381438    $publish_callback_args = array( '__back_compat_meta_box' => true );
     1439
    14391440    if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
    14401441        $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
     
    14421443        // We should aim to show the revisions meta box only when there are revisions.
    14431444        if ( count( $revisions ) > 1 ) {
    1444             reset( $revisions ); // Reset pointer for key().
    14451445            $publish_callback_args = array(
    14461446                'revisions_count'        => count( $revisions ),
    1447                 'revision_id'            => array_shift( $revisions ),
     1447                'revision_id'            => reset( $revisions ),
    14481448                '__back_compat_meta_box' => true,
    14491449            );
     1450
    14501451            add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    14511452        }
Note: See TracChangeset for help on using the changeset viewer.