From 2960eb4dd2bada8442140540aa6c696445cf9bd2 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 30 Apr 2015 16:14:53 +0800 Subject: [PATCH] MDL-50066 strings: unable to deprecate string from moodle.php --- lib/classes/string_manager_standard.php | 6 ++++-- lib/tests/string_manager_standard_test.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/classes/string_manager_standard.php b/lib/classes/string_manager_standard.php index 6482c67e28a..38687d19d1d 100644 --- a/lib/classes/string_manager_standard.php +++ b/lib/classes/string_manager_standard.php @@ -256,7 +256,8 @@ class core_string_manager_standard implements core_string_manager { public function string_deprecated($identifier, $component) { $deprecated = $this->load_deprecated_strings(); list($plugintype, $pluginname) = core_component::normalize_component($component); - return isset($deprecated[$identifier . ',' . $plugintype . '_' . $pluginname]); + $normcomponent = $pluginname ? ($plugintype . '_' . $pluginname) : $plugintype; + return isset($deprecated[$identifier . ',' . $normcomponent]); } /** @@ -383,7 +384,8 @@ class core_string_manager_standard implements core_string_manager { // Display a debugging message if sting exists but was deprecated. if ($this->string_deprecated($identifier, $component)) { list($plugintype, $pluginname) = core_component::normalize_component($component); - debugging("String [{$identifier},{$plugintype}_{$pluginname}] is deprecated. ". + $normcomponent = $pluginname ? ($plugintype . '_' . $pluginname) : $plugintype; + debugging("String [{$identifier},{$normcomponent}] is deprecated. ". 'Either you should no longer be using that string, or the string has been incorrectly deprecated, in which case you should report this as a bug. '. 'Please refer to https://docs.moodle.org/dev/String_deprecation', DEBUG_DEVELOPER); } diff --git a/lib/tests/string_manager_standard_test.php b/lib/tests/string_manager_standard_test.php index 1507b88175b..ae7fc1b0f78 100644 --- a/lib/tests/string_manager_standard_test.php +++ b/lib/tests/string_manager_standard_test.php @@ -101,7 +101,8 @@ class core_string_manager_standard_testcase extends advanced_testcase { $this->fail('String "'.$string.'" appearing in one of the lang/en/deprecated.txt files does not have correct syntax'); } list($pluginttype, $pluginname) = core_component::normalize_component($matches[2]); - if ($matches[2] !== $pluginttype . '_' . $pluginname) { + $normcomponent = $pluginname ? ($pluginttype . '_' . $pluginname) : $pluginttype; + if ($matches[2] !== $normcomponent) { $this->fail('String "'.$string.'" appearing in one of the lang/en/deprecated.txt files does not have normalised component name'); } if (!$stringman->string_exists($matches[1], $matches[2])) {