WordPress.org

Make WordPress Core

Changeset 48438


Ignore:
Timestamp:
07/11/2020 09:13:56 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Revisions: Restore the return value of wp_get_post_autosave() to the documented type of WP_Post for backward compatibility.

Follow-up to [48422].

See #34560.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/revision.php

    r48422 r48438  
    222222 * Retrieve the autosaved data of the specified post.
    223223 *
    224  * Returns an object containing the information that was autosaved for the
    225  * specified post. If the optional $user_id is passed, returns the autosave for that user
    226  * otherwise returns the latest autosave.
     224 * Returns a post object with the information that was autosaved for the specified post.
     225 * If the optional $user_id is passed, returns the autosave for that user, otherwise
     226 * returns the latest autosave.
    227227 *
    228228 * @since 2.6.0
     
    238238    $user_id_query = ( 0 !== $user_id ) ? "AND post_author = $user_id" : null;
    239239
    240     // Construct the autosave query
     240    // Construct the autosave query.
    241241    $autosave_query = "
    242242        SELECT *
     
    261261    }
    262262
    263     return $autosave[0];
     263    return get_post( $autosave[0] );
    264264}
    265265
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r48422 r48438  
    473473        $this->assertEquals( 'draft', $this->_last_response_parsed['data']['changeset_status'] );
    474474        $autosave_revision = wp_get_post_autosave( $post_id );
    475         $this->assertInstanceOf( 'stdClass', $autosave_revision );
     475        $this->assertInstanceOf( 'WP_Post', $autosave_revision );
    476476
    477477        $this->assertContains( 'New Site Title', get_post( $post_id )->post_content );
     
    700700        $this->assertNotWPError( $r );
    701701        $autosave_revision = wp_get_post_autosave( $wp_customize->changeset_post_id() );
    702         $this->assertInstanceOf( 'stdClass', $autosave_revision );
     702        $this->assertInstanceOf( 'WP_Post', $autosave_revision );
    703703        $this->assertContains( 'Foo', get_post( $wp_customize->changeset_post_id() )->post_content );
    704704        $this->assertContains( 'Bar', $autosave_revision->post_content );
  • trunk/tests/phpunit/tests/customize/manager.php

    r48422 r48438  
    18921892        // Verify that autosave happened.
    18931893        $autosave_revision = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
    1894         $this->assertInstanceOf( 'stdClass', $autosave_revision );
     1894        $this->assertInstanceOf( 'WP_Post', $autosave_revision );
    18951895        $this->assertContains( 'Draft Title', get_post( $changeset_post_id )->post_content );
    18961896        $this->assertContains( 'Autosave Title', $autosave_revision->post_content );
Note: See TracChangeset for help on using the changeset viewer.