From 7b61df725e2838e9a8c58db34ed00755081ff9cf Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 11 Jul 2020 12:30:02 +0000 Subject: [PATCH] Revisions: Replace `array_shift()` with `reset()` in `register_and_do_post_meta_boxes()` for better performance. Follow-up to [31829], [48422]. See #34560. Built from https://develop.svn.wordpress.org/trunk@48436 git-svn-id: http://core.svn.wordpress.org/trunk@48205 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/meta-boxes.php | 5 +++-- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 95513ae74e..f79e0d6196 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -1436,17 +1436,18 @@ 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, 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' => array_shift( $revisions ), + 'revision_id' => reset( $revisions ), '__back_compat_meta_box' => true, ); + add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index a78e1950d7..d4286b9069 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta1-48435'; +$wp_version = '5.5-beta1-48436'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.