# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: moodle/webservice/amf/locallib.php --- moodle/webservice/amf/locallib.php Base (1.5) +++ moodle/webservice/amf/locallib.php Locally Modified (Based On 1.5) @@ -62,13 +62,22 @@ } protected function service_class_method_body($function, $params){ + //cast the param from object to array (validate_parameters except array only) + $castingcode = ''; if ($params){ - $params = "webservice_amf_server::cast_objects_to_array($params)"; + $paramstocast = split(',', $params); + foreach ($paramstocast as $paramtocast) { + $paramtocast = trim($paramtocast); + $castingcode .= $paramtocast . + '=webservice_zend_server::cast_objects_to_array('.$paramtocast.');'; } + + } + $externallibcall = $function->classname.'::'.$function->methodname.'('.$params.')'; $descriptionmethod = $function->methodname.'_returns()'; $callforreturnvaluedesc = $function->classname.'::'.$descriptionmethod; - return + return $castingcode . ' return webservice_amf_server::validate_and_cast_values('.$callforreturnvaluedesc.', '.$externallibcall.');'; } /** @@ -138,28 +147,8 @@ throw new invalid_return_value_exception('Invalid external api description.'); } } + /** - * Recursive function to recurse down into a complex variable and convert all - * objects to arrays. Doesn't recurse down into objects or cast objects other than stdClass - * which is represented in Flash / Flex as an object. - * @param mixed $params value to cast - * @return mixed Cast value - */ - public static function cast_objects_to_array($params){ - if ($params instanceof stdClass){ - $params = (array)$params; - } - if (is_array($params)){ - $toreturn = array(); - foreach ($params as $key=> $param){ - $toreturn[$key] = self::cast_objects_to_array($param); - } - return $toreturn; - } else { - return $params; - } - } - /** * Set up zend service class * @return void */