diff --git a/lib/external/externallib.php b/lib/external/externallib.php index 5ba6a5e3aa6..c69681d0e4c 100644 --- a/lib/external/externallib.php +++ b/lib/external/externallib.php @@ -236,7 +236,10 @@ class core_external extends external_api { $wsstrings = array(); $componentstrings = $stringmanager->load_component_strings($params['component'], $params['lang']); foreach($componentstrings as $stringid => $string) { - $wsstrings[$stringid] = $string; + $wsstring = array(); + $wsstring['stringid'] = $stringid; + $wsstring['string'] = $string; + $wsstrings[] = $wsstring; } return $wsstrings; @@ -252,7 +255,7 @@ class core_external extends external_api { return new external_multiple_structure( new external_single_structure(array( 'stringid' => new external_value(PARAM_STRINGID, 'string id'), - 'string' => new external_value(PARAM_TEXT, 'translated string')) + 'string' => new external_value(PARAM_RAW, 'translated string')) )); } } diff --git a/lib/external/tests/externallib_test.php b/lib/external/tests/externallib_test.php index 815b97e9347..5c4b2089855 100644 --- a/lib/external/tests/externallib_test.php +++ b/lib/external/tests/externallib_test.php @@ -105,9 +105,13 @@ class core_external_testcase extends externallib_advanced_testcase { $wsstrings = $stringmanager->load_component_strings('webservice', current_language()); $componentstrings = core_external::get_component_strings('webservice'); + + // We need to execute the return values cleaning process to simulate the web service server. + $componentstrings = external_api::clean_returnvalue(core_external::get_component_strings_returns(), $componentstrings); + $this->assertEquals(count($componentstrings), count($wsstrings)); - foreach($wsstrings as $name => $string) { - $this->assertEquals($string, $componentstrings[$name]); + foreach($componentstrings as $string) { + $this->assertEquals($string['string'], $wsstrings[$string['stringid']]); } } }