REST API: Ensure string returned in WP_REST_Templates_Controller::get_wp_templates_author_text_field().

Adds a fail-safe to return an empty string should the `switch` ever fall through without returning.

Currently, `WP_REST_Templates_Controller::get_wp_templates_author_text_field()` is tightly coupled to `WP_REST_Templates_Controller::get_wp_templates_original_source_field()`. However, if the `$original_source` values change in either method, but not both, it is possible a `void` or `null` will be returned, rather than a `string`.

Follow-up to [57366].

Props antonvlasenko, hellofromTonya, debarghyabanerjee.
Fixes #61580.
Built from https://develop.svn.wordpress.org/trunk@58705


git-svn-id: http://core.svn.wordpress.org/trunk@58107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2024-07-10 21:25:11 +00:00
parent a5efdd1cc9
commit 70c9c49f9b
2 changed files with 4 additions and 1 deletions

View File

@ -871,6 +871,9 @@ class WP_REST_Templates_Controller extends WP_REST_Controller {
}
return $author->get( 'display_name' );
}
// Fail-safe to return a string should the original source ever fall through.
return '';
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58704';
$wp_version = '6.7-alpha-58705';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.