mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
I18N: Bail early if an invalid text domain is passed to load_textdomain()
et al.
Some plugins pass invalid values such as `null` instead of a string, which has never been supported by WordPress (no translations are loaded) and was technically undefined behavior. With the introduction of the new l10n library in #59656, which has stricter type hints, this could end up causing warnings or even fatal errors. This change adds a deliberate short-circuit to `load_textdomain()` & co. to better handle such a case and document that it is not supported. Props verygoode, swissspidy. Fixes #60888. Built from https://develop.svn.wordpress.org/trunk@57925 git-svn-id: http://core.svn.wordpress.org/trunk@57426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f09686a12a
commit
1c8b25a7a5
@ -728,6 +728,10 @@ function load_textdomain( $domain, $mofile, $locale = null ) {
|
||||
|
||||
$l10n_unloaded = (array) $l10n_unloaded;
|
||||
|
||||
if ( ! is_string( $domain ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters whether to short-circuit loading .mo file.
|
||||
*
|
||||
@ -989,6 +993,10 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
|
||||
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
|
||||
global $wp_textdomain_registry;
|
||||
|
||||
if ( ! is_string( $domain ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a plugin's locale.
|
||||
*
|
||||
@ -1037,6 +1045,10 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
|
||||
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
|
||||
global $wp_textdomain_registry;
|
||||
|
||||
if ( ! is_string( $domain ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/l10n.php */
|
||||
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
|
||||
|
||||
@ -1076,6 +1088,10 @@ function load_theme_textdomain( $domain, $path = false ) {
|
||||
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
|
||||
global $wp_textdomain_registry;
|
||||
|
||||
if ( ! is_string( $domain ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a theme's locale.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-57924';
|
||||
$wp_version = '6.6-alpha-57925';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user