mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-37381 core_external::get_component_strings returns wrong format value
This commit is contained in:
parent
9da506c2a3
commit
c5f7628d39
7
lib/external/externallib.php
vendored
7
lib/external/externallib.php
vendored
@ -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'))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
8
lib/external/tests/externallib_test.php
vendored
8
lib/external/tests/externallib_test.php
vendored
@ -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']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user