diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 890638eba4..e822d7c40f 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -1459,13 +1459,13 @@ 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' ) ); + $revisions = wp_get_latest_revision_id_and_total_count( $post->ID ); // We should aim to show the revisions meta box only when there are revisions. - if ( count( $revisions ) > 1 ) { + if ( ! is_wp_error( $revisions ) && $revisions['count'] > 1 ) { $publish_callback_args = array( - 'revisions_count' => count( $revisions ), - 'revision_id' => reset( $revisions ), + 'revisions_count' => $revisions['count'], + 'revision_id' => $revisions['latest_id'], '__back_compat_meta_box' => true, ); diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 95a7c507fa..584baf2336 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -603,14 +603,13 @@ function wp_get_post_revisions_url( $post = 0 ) { return null; } - $revisions = wp_get_post_revisions( $post->ID, array( 'posts_per_page' => 1 ) ); + $revisions = wp_get_latest_revision_id_and_total_count( $post->ID ); - if ( 0 === count( $revisions ) ) { + if ( is_wp_error( $revisions ) || 0 === $revisions['count'] ) { return null; } - $revision = reset( $revisions ); - return get_edit_post_link( $revision ); + return get_edit_post_link( $revisions['latest_id'] ); } /** diff --git a/wp-includes/theme.php b/wp-includes/theme.php index ef49f07e14..3c7b297b2a 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -2068,7 +2068,8 @@ function wp_update_custom_css_post( $css, $args = array() ) { } // Trigger creation of a revision. This should be removed once #30854 is resolved. - if ( 0 === count( wp_get_post_revisions( $r ) ) ) { + $revisions = wp_get_latest_revision_id_and_total_count( $r ); + if ( ! is_wp_error( $revisions ) && 0 === $revisions['count'] ) { wp_save_post_revision( $r ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index ce1fcca5ff..08c4a22455 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53841'; +$wp_version = '6.1-alpha-53842'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.