From d08f2f1175c7919cdab32f0f3a492ba9eda67ef1 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 2 Apr 2015 15:42:51 +0800 Subject: [PATCH] MDL-49560 webservice: avoid recursion in soap Thanks to El Leonidych for providing a patch --- webservice/soap/locallib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webservice/soap/locallib.php b/webservice/soap/locallib.php index 8ccd31757af..13862560acf 100644 --- a/webservice/soap/locallib.php +++ b/webservice/soap/locallib.php @@ -273,11 +273,6 @@ class webservice_soap_server extends webservice_zend_server { */ protected function generate_simple_struct_class(external_single_structure $structdesc) { 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(); foreach ($structdesc->keys as $name => $fieldsdesc) { @@ -286,6 +281,12 @@ class webservice_soap_server extends webservice_zend_server { ' 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 = ' /** * Virtual struct class for web services for user id '.$USER->id.' in context '.$this->restricted_context->id.'.