Changeset 53778
- Timestamp:
- 07/25/2022 07:18:41 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r53769 r53778 2027 2027 2028 2028 if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) { 2029 $revision = wp_get_la st_revision_id_and_total_count( $post->ID );2029 $revision = wp_get_latest_revision_id_and_total_count( $post->ID ); 2030 2030 $revisions_count = ! is_wp_error( $revision ) ? $revision['count'] : 0; 2031 2031 … … 2036 2036 2037 2037 if ( $revisions_count > 0 ) { 2038 $la st_revision = $revision['revision'];2038 $latest_revision = $revision['revision']; 2039 2039 2040 2040 $links['predecessor-version'] = array( 2041 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $la st_revision ),2042 'id' => $la st_revision,2041 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $latest_revision ), 2042 'id' => $latest_revision, 2043 2043 ); 2044 2044 } -
trunk/src/wp-includes/revision.php
r53770 r53778 535 535 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 536 536 * @return WP_Error|array { 537 * Returns associative array with la st revision ID and total count.538 * 539 * @type int $revision The la st revision post ID or 0 if no revisions exist.537 * Returns associative array with latest revision ID and total count. 538 * 539 * @type int $revision The latest revision post ID or 0 if no revisions exist. 540 540 * @type int $count The total count of revisions for the given post. 541 541 * } 542 542 */ 543 function wp_get_la st_revision_id_and_total_count( $post = 0 ) {543 function wp_get_latest_revision_id_and_total_count( $post = 0 ) { 544 544 $post = get_post( $post ); 545 545 -
trunk/tests/phpunit/tests/post/revisions.php
r53769 r53778 657 657 658 658 /** 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 661 662 * @ticket 55857 662 663 * @dataProvider data_wp_get_post_revisions_url 663 664 */ 664 public function test_wp_get_la st_revision_id_and_total_count( $revisions ) {665 public function test_wp_get_latest_revision_id_and_total_count( $revisions ) { 665 666 $post_id = self::factory()->post->create(); 666 667 for ( $i = 0; $i < $revisions; ++$i ) { … … 673 674 } 674 675 675 $post_revisions = wp_get_post_revisions( $post_id );676 $la st_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 ); 678 679 679 680 $this->assertSame( 680 $la st_post_revision->ID,681 $latest_post_revision->ID, 681 682 $revision['revision'], 682 'The la st revision ID does not match.'683 'The latest revision ID does not match.' 683 684 ); 684 685 … … 691 692 692 693 /** 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 695 697 * @ticket 55857 696 698 */ 697 public function test_wp_get_la st_revision_id_and_total_count_no_revisions() {698 $revision = wp_get_la st_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 ); 699 701 700 702 $this->assertWPError( $revision, 'Invalid post, no revisions should exist.' ); … … 703 705 add_filter( 'wp_revisions_to_keep', '__return_zero' ); 704 706 $post_id = self::factory()->post->create(); 705 $revision = wp_get_la st_revision_id_and_total_count( $post_id );707 $revision = wp_get_latest_revision_id_and_total_count( $post_id ); 706 708 707 709 $this->assertWPError( $revision, 'Revisions should not be enabled.' );
Note: See TracChangeset
for help on using the changeset viewer.