MDL-60738 webservice: Clean theme and lang properly

Sometimes the "theme" and "lang" fields in the user and course tables
in the database are set to incorrect values (uninstalled or
non-existent themes and language packs).
This makes Web Services functions to fail because the WS server
validate the returned data using the validate_param function that clean
parameters.
This commit is contained in:
Juan Leyva
2017-11-20 09:38:03 +01:00
parent 665c3ac59c
commit e84e1bbff3
8 changed files with 60 additions and 13 deletions
+8
View File
@@ -564,6 +564,14 @@ function user_get_user_details($user, $course = null, array $userfields = array(
}
}
// Clean lang and auth fields for external functions (it may content uninstalled themes or language packs).
if (isset($userdetails['lang'])) {
$userdetails['lang'] = clean_param($userdetails['lang'], PARAM_LANG);
}
if (isset($userdetails['theme'])) {
$userdetails['theme'] = clean_param($userdetails['theme'], PARAM_THEME);
}
return $userdetails;
}