Commit 8434b88e authored by Robert Lyon's avatar Robert Lyon
Browse files

Fixing problem with testclient unable to create / update user



behatnotneeded

Change-Id: Ic7d4ea2fb48228dcea5504cc8404bf0aa2474152
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c740a5cf
......@@ -232,7 +232,7 @@ class mahara_user_external extends external_api {
// we need to turn the social profile information into a single string to pass validate_paramaters()
foreach ($users as $key => $user) {
if (isset($user['socialprofile'])) {
if (isset($user['socialprofile']) && is_array($user['socialprofile'])) {
$users[$key]['socialprofile'] = (!empty($user['socialprofile']['profiletype']) ? $user['socialprofile']['profiletype'] : '') . '|' . (!empty($user['socialprofile']['profileurl']) ? $user['socialprofile']['profileurl'] : '');
}
}
......@@ -481,7 +481,7 @@ class mahara_user_external extends external_api {
// we need to turn the social profile information into a single string to pass validate_paramaters()
foreach ($users as $key => $user) {
if (isset($user['socialprofile'])) {
if (isset($user['socialprofile']) && is_array($user['socialprofile'])) {
$users[$key]['socialprofile'] = (!empty($user['socialprofile']['profiletype']) ? $user['socialprofile']['profiletype'] : '') . '|' . (!empty($user['socialprofile']['profileurl']) ? $user['socialprofile']['profileurl'] : '');
}
}
......
......@@ -555,6 +555,11 @@ class external_api {
* @return mixed params with added defaults for optional items, invalid_parameters_exception thrown if any problem found
*/
public static function validate_parameters(external_description $description, $params) {
// we need to turn the social profile information into a single string to pass external_value test
// because we can either pass in the information as a string 'profiletype|profileurl' or as an array
if (isset($params['socialprofile']) && is_array($params['socialprofile'])) {
$params['socialprofile'] = (!empty($params['socialprofile']['profiletype']) ? $params['socialprofile']['profiletype'] : '') . '|' . (!empty($params['socialprofile']['profileurl']) ? $params['socialprofile']['profileurl'] : '');
}
if ($description instanceof external_value) {
if (is_array($params) or is_object($params)) {
throw new WebserviceInvalidParameterException(get_string('errorscalartype', 'auth.webservice'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment