Make WordPress Core


Ignore:
Timestamp:
07/25/2022 07:18:41 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Revisions: Rename the function for retrieving the latest revision ID and total count.

The new name is wp_get_latest_revision_id_and_total_count().

This aims to reduce ambiguity about what exactly is the "first" or "last" revision, and bring more consistency with similar wording elsewhere in core, e.g. latest posts, latest comments, etc.

Follow-up to [53759], [53769].

Props peterwilsoncc.
See #55857.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/revisions.php

    r53769 r53778  
    657657
    658658    /**
    659      * Tests that wp_get_last_revision_id_and_total_count() returns the last revision ID and total count.
    660      *
     659     * Tests that wp_get_latest_revision_id_and_total_count() returns the latest revision ID and total count.
     660     *
     661     * @covers ::wp_get_latest_revision_id_and_total_count
    661662     * @ticket 55857
    662663     * @dataProvider data_wp_get_post_revisions_url
    663664     */
    664     public function test_wp_get_last_revision_id_and_total_count( $revisions ) {
     665    public function test_wp_get_latest_revision_id_and_total_count( $revisions ) {
    665666        $post_id = self::factory()->post->create();
    666667        for ( $i = 0; $i < $revisions; ++$i ) {
     
    673674        }
    674675
    675         $post_revisions     = wp_get_post_revisions( $post_id );
    676         $last_post_revision = current( $post_revisions );
    677         $revision           = wp_get_last_revision_id_and_total_count( $post_id );
     676        $post_revisions       = wp_get_post_revisions( $post_id );
     677        $latest_post_revision = current( $post_revisions );
     678        $revision             = wp_get_latest_revision_id_and_total_count( $post_id );
    678679
    679680        $this->assertSame(
    680             $last_post_revision->ID,
     681            $latest_post_revision->ID,
    681682            $revision['revision'],
    682             'The last revision ID does not match.'
     683            'The latest revision ID does not match.'
    683684        );
    684685
     
    691692
    692693    /**
    693      * Tests that wp_get_last_revision_id_and_total_count() returns a WP_Error when no revisions exist.
    694      *
     694     * Tests that wp_get_latest_revision_id_and_total_count() returns a WP_Error when no revisions exist.
     695     *
     696     * @covers ::wp_get_latest_revision_id_and_total_count
    695697     * @ticket 55857
    696698     */
    697     public function test_wp_get_last_revision_id_and_total_count_no_revisions() {
    698         $revision = wp_get_last_revision_id_and_total_count( null );
     699    public function test_wp_get_latest_revision_id_and_total_count_no_revisions() {
     700        $revision = wp_get_latest_revision_id_and_total_count( null );
    699701
    700702        $this->assertWPError( $revision, 'Invalid post, no revisions should exist.' );
     
    703705        add_filter( 'wp_revisions_to_keep', '__return_zero' );
    704706        $post_id  = self::factory()->post->create();
    705         $revision = wp_get_last_revision_id_and_total_count( $post_id );
     707        $revision = wp_get_latest_revision_id_and_total_count( $post_id );
    706708
    707709        $this->assertWPError( $revision, 'Revisions should not be enabled.' );
Note: See TracChangeset for help on using the changeset viewer.