wp-includes/revision.php:279Retrieves the autosaved data of the specified post.
$post_idint$user_idintoptional0WP_Post|falsefunction wp_get_post_autosave( $post_id, $user_id = 0 ) { global $wpdb; $autosave_name = $post_id . '-autosave-v1'; $user_id_query = ( 0 !== $user_id ) ? "AND post_author = $user_id" : null; // Construct the autosave query. $autosave_query = " SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision' AND post_status = 'inherit' AND post_name = %s " . $user_id_query . ' ORDER BY post_date DESC LIMIT 1'; $autosave = $wpdb->get_results( $wpdb->prepare( $autosave_query, $post_id, $autosave_name ) ); if ( ! $autosave ) { return false; } return get_post( $autosave[0] );}Introduced in 2.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/revision.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.