Commit 11c16f5f authored by Damyon Wiese's avatar Damyon Wiese Committed by David Monllaó
Browse files

MDL-53772 externallib: Deprecate external_function_info()

parent e02e7f5a
...@@ -33,7 +33,7 @@ admin_externalpage_setup('webservicedocumentation'); ...@@ -33,7 +33,7 @@ admin_externalpage_setup('webservicedocumentation');
$functions = $DB->get_records('external_functions', array(), 'name'); $functions = $DB->get_records('external_functions', array(), 'name');
$functiondescs = array(); $functiondescs = array();
foreach ($functions as $function) { foreach ($functions as $function) {
$functiondescs[$function->name] = external_function_info($function); $functiondescs[$function->name] = external_api::external_function_info($function);
} }
//display the documentation for all documented protocols, //display the documentation for all documented protocols,
......
...@@ -196,7 +196,7 @@ class external_service_functions_form extends moodleform { ...@@ -196,7 +196,7 @@ class external_service_functions_form extends moodleform {
//we add the descriptions to the functions //we add the descriptions to the functions
foreach ($functions as $functionid => $functionname) { foreach ($functions as $functionid => $functionname) {
//retrieve full function information (including the description) //retrieve full function information (including the description)
$function = external_function_info($functionname); $function = external_api::external_function_info($functionname);
if (empty($function->deprecated)) { if (empty($function->deprecated)) {
$functions[$functionid] = $function->name . ':' . $function->description; $functions[$functionid] = $function->name . ':' . $function->description;
} else { } else {
......
...@@ -49,7 +49,7 @@ admin_externalpage_setup('testclient'); ...@@ -49,7 +49,7 @@ admin_externalpage_setup('testclient');
$allfunctions = $DB->get_records('external_functions', array(), 'name ASC'); $allfunctions = $DB->get_records('external_functions', array(), 'name ASC');
$functions = array(); $functions = array();
foreach ($allfunctions as $f) { foreach ($allfunctions as $f) {
$finfo = external_function_info($f); $finfo = external_api::external_function_info($f);
if (!empty($finfo->testclientpath) and file_exists($CFG->dirroot.'/'.$finfo->testclientpath)) { if (!empty($finfo->testclientpath) and file_exists($CFG->dirroot.'/'.$finfo->testclientpath)) {
//some plugins may want to have own test client forms //some plugins may want to have own test client forms
include_once($CFG->dirroot.'/'.$finfo->testclientpath); include_once($CFG->dirroot.'/'.$finfo->testclientpath);
...@@ -113,7 +113,7 @@ if ($mform->is_cancelled()) { ...@@ -113,7 +113,7 @@ if ($mform->is_cancelled()) {
} else if ($data = $mform->get_data()) { } else if ($data = $mform->get_data()) {
$functioninfo = external_function_info($function); $functioninfo = external_api::external_function_info($function);
// first load lib of selected protocol // first load lib of selected protocol
require_once("$CFG->dirroot/webservice/$protocol/locallib.php"); require_once("$CFG->dirroot/webservice/$protocol/locallib.php");
......
...@@ -4473,3 +4473,20 @@ function site_scale_used($scaleid, &$courses) { ...@@ -4473,3 +4473,20 @@ function site_scale_used($scaleid, &$courses) {
} }
return $return; return $return;
} }
/**
* Returns detailed function information
*
* @deprecated since Moodle 3.1
* @param string|object $function name of external function or record from external_function
* @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
* MUST_EXIST means throw exception if no record or multiple records found
* @return stdClass description or false if not found or exception thrown
* @since Moodle 2.0
*/
function external_function_info($function, $strictness=MUST_EXIST) {
debugging('external_function_info() is deprecated. Please use external_api::external_function_info() instead.',
DEBUG_DEVELOPER);
return external_api::external_function_info($function, $strictness);
}
...@@ -25,19 +25,6 @@ ...@@ -25,19 +25,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* Returns detailed function information
*
* @param string|object $function name of external function or record from external_function
* @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
* MUST_EXIST means throw exception if no record or multiple records found
* @return stdClass description or false if not found or exception thrown
* @since Moodle 2.0
*/
function external_function_info($function, $strictness=MUST_EXIST) {
return external_api::external_function_info($function, $strictness);
}
/** /**
* Exception indicating user is not allowed to use external function in the current context. * Exception indicating user is not allowed to use external function in the current context.
* *
......
...@@ -317,7 +317,7 @@ class core_externallib_testcase extends advanced_testcase { ...@@ -317,7 +317,7 @@ class core_externallib_testcase extends advanced_testcase {
* @dataProvider all_external_info_provider * @dataProvider all_external_info_provider
*/ */
public function test_all_external_info($f) { public function test_all_external_info($f) {
$desc = external_function_info($f); $desc = external_api::external_function_info($f);
$this->assertNotEmpty($desc->name); $this->assertNotEmpty($desc->name);
$this->assertNotEmpty($desc->classname); $this->assertNotEmpty($desc->classname);
$this->assertNotEmpty($desc->methodname); $this->assertNotEmpty($desc->methodname);
......
...@@ -1246,7 +1246,7 @@ abstract class webservice_base_server extends webservice_server { ...@@ -1246,7 +1246,7 @@ abstract class webservice_base_server extends webservice_server {
} }
// function must exist // function must exist
$function = external_function_info($this->functionname); $function = external_api::external_function_info($this->functionname);
if ($this->restricted_serviceid) { if ($this->restricted_serviceid) {
$params = array('sid1'=>$this->restricted_serviceid, 'sid2'=>$this->restricted_serviceid); $params = array('sid1'=>$this->restricted_serviceid, 'sid2'=>$this->restricted_serviceid);
...@@ -1475,7 +1475,7 @@ EOD; ...@@ -1475,7 +1475,7 @@ EOD;
* @throws moodle_exception * @throws moodle_exception
*/ */
protected function get_virtual_method_code($function) { protected function get_virtual_method_code($function) {
$function = external_function_info($function); $function = external_api::external_function_info($function);
// Parameters and their defaults for the method signature. // Parameters and their defaults for the method signature.
$paramanddefaults = array(); $paramanddefaults = array();
......
...@@ -216,7 +216,7 @@ class core_webservice_renderer extends plugin_renderer_base { ...@@ -216,7 +216,7 @@ class core_webservice_renderer extends plugin_renderer_base {
$anydeprecated = false; $anydeprecated = false;
foreach ($functions as $function) { foreach ($functions as $function) {
$function = external_function_info($function); $function = external_api::external_function_info($function);
if (!empty($function->deprecated)) { if (!empty($function->deprecated)) {
$anydeprecated = true; $anydeprecated = true;
......
...@@ -121,7 +121,7 @@ class webservice_test extends advanced_testcase { ...@@ -121,7 +121,7 @@ class webservice_test extends advanced_testcase {
// Check the contents of service methods. // Check the contents of service methods.
foreach ($servicemethods as $method) { foreach ($servicemethods as $method) {
// Get the external function info. // Get the external function info.
$function = external_function_info($method->name); $function = external_api::external_function_info($method->name);
// Check input params. // Check input params.
foreach ($function->parameters_desc->keys as $name => $keydesc) { foreach ($function->parameters_desc->keys as $name => $keydesc) {
......
...@@ -67,7 +67,7 @@ $functions = $webservice->get_external_functions(array($token->externalserviceid ...@@ -67,7 +67,7 @@ $functions = $webservice->get_external_functions(array($token->externalserviceid
// get all the function descriptions // get all the function descriptions
$functiondescs = array(); $functiondescs = array();
foreach ($functions as $function) { foreach ($functions as $function) {
$functiondescs[$function->name] = external_function_info($function); $functiondescs[$function->name] = external_api::external_function_info($function);
} }
// get activated protocol // get activated protocol
......
Supports Markdown
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