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
This commit is contained in:
parent
463644fc6d
commit
7b61df725e
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue