diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php index 22cdc268fa..c0bc7663e1 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php @@ -170,7 +170,17 @@ class WP_REST_Template_Revisions_Controller extends WP_REST_Revisions_Controller return new WP_Error( 'rest_post_invalid_parent', __( 'Invalid template parent ID.' ), - array( 'status' => 404 ) + array( 'status' => WP_Http::NOT_FOUND ) + ); + } + + $parent_post_id = isset( $template->wp_id ) ? (int) $template->wp_id : 0; + + if ( $parent_post_id <= 0 ) { + return new WP_Error( + 'rest_invalid_template', + __( 'Templates based on theme files can\'t have revisions.' ), + array( 'status' => WP_Http::BAD_REQUEST ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 148a4be49a..7acd45aaf2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59604'; +$wp_version = '6.8-alpha-59605'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.