From 51473acfb37e422b3516fc608b2c3dc2a8f5d55e Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 16 Feb 2016 21:15:29 +0000 Subject: [PATCH] i18n: Prevent `is_textdomain_loaded()` from returning true even if there are no translations for the domain. In `get_translations_for_domain()` don't fill the global `$l10n` with `NOOP_Translations` instances, return a `NOOP_Translations` instance instead. Props nacin, jrf. Fixes #21319. Built from https://develop.svn.wordpress.org/trunk@36538 git-svn-id: http://core.svn.wordpress.org/trunk@36505 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 14 ++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index de02d5a846..ed0b940c13 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -793,10 +793,16 @@ function load_child_theme_textdomain( $domain, $path = false ) { */ function get_translations_for_domain( $domain ) { global $l10n; - if ( !isset( $l10n[$domain] ) ) { - $l10n[$domain] = new NOOP_Translations; + if ( isset( $l10n[ $domain ] ) ) { + return $l10n[ $domain ]; } - return $l10n[$domain]; + + static $noop_translations = null; + if ( null === $noop_translations ) { + $noop_translations = new NOOP_Translations; + } + + return $noop_translations; } /** @@ -811,7 +817,7 @@ function get_translations_for_domain( $domain ) { */ function is_textdomain_loaded( $domain ) { global $l10n; - return isset( $l10n[$domain] ); + return isset( $l10n[ $domain ] ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 777b089030..3d0572b21f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36537'; +$wp_version = '4.5-alpha-36538'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.