MDL-49560 webservice: avoid recursion in soap

Thanks to El Leonidych for providing a patch
This commit is contained in:
Marina Glancy 2015-04-02 15:42:51 +08:00 committed by Dave Cooper
parent 803f565753
commit d08f2f1175

View file

@ -273,11 +273,6 @@ class webservice_soap_server extends webservice_zend_server {
*/ */
protected function generate_simple_struct_class(external_single_structure $structdesc) { protected function generate_simple_struct_class(external_single_structure $structdesc) {
global $USER; global $USER;
// let's use unique class name, there might be problem in unit tests
$classname = 'webservices_struct_class_000000';
while(class_exists($classname)) {
$classname++;
}
$fields = array(); $fields = array();
foreach ($structdesc->keys as $name => $fieldsdesc) { foreach ($structdesc->keys as $name => $fieldsdesc) {
@ -286,6 +281,12 @@ class webservice_soap_server extends webservice_zend_server {
' public $'.$name.';'; ' public $'.$name.';';
} }
// We do this after the call to get_phpdoc_type() to avoid duplicate class creation.
$classname = 'webservices_struct_class_000000';
while (class_exists($classname)) {
$classname++;
}
$code = ' $code = '
/** /**
* Virtual struct class for web services for user id '.$USER->id.' in context '.$this->restricted_context->id.'. * Virtual struct class for web services for user id '.$USER->id.' in context '.$this->restricted_context->id.'.