Skip to content

Commit

Permalink
MDL-43535 webservices: Marking functions as deprecated
Browse files Browse the repository at this point in the history
Also:
- We don't allow users to add deprecated functions to WS
- We show a debugging message when deprecated functions
  are already being used in web services.
  • Loading branch information
David Monllao committed Feb 8, 2015
1 parent 88cd577 commit 3c1aa6f
Show file tree
Hide file tree
Showing 17 changed files with 363 additions and 68 deletions.
7 changes: 6 additions & 1 deletion admin/webservice/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ function definition() {
foreach ($functions as $functionid => $functionname) {
//retrieve full function information (including the description)
$function = external_function_info($functionname);
$functions[$functionid] = $function->name . ':' . $function->description;
if (empty($function->deprecated)) {
$functions[$functionid] = $function->name . ':' . $function->description;
} else {
// Exclude the deprecated ones.
unset($functions[$functionid]);
}
}

$mform->addElement('searchableselector', 'fids', get_string('name'),
Expand Down
17 changes: 17 additions & 0 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,15 @@ public static function get_courses_returns() {
return core_course_external::get_courses_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_courses_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
*
Expand Down Expand Up @@ -2019,4 +2028,12 @@ public static function create_courses_returns() {
return core_course_external::create_courses_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function create_courses_is_deprecated() {
return true;
}
}
34 changes: 34 additions & 0 deletions enrol/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,15 @@ public static function get_enrolled_users_returns() {
);
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_enrolled_users_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
*
Expand Down Expand Up @@ -960,6 +969,14 @@ public static function get_users_courses_returns() {
return core_enrol_external::get_users_courses_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_users_courses_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
Expand Down Expand Up @@ -997,6 +1014,14 @@ public static function role_assign_returns() {
return core_role_external::assign_roles_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function role_assign_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
Expand Down Expand Up @@ -1033,4 +1058,13 @@ public static function role_unassign($unassignments) {
public static function role_unassign_returns() {
return core_role_external::unassign_roles_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function role_unassign_is_deprecated() {
return true;
}
}
4 changes: 2 additions & 2 deletions enrol/manual/db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

// === enrol related functions ===
'moodle_enrol_manual_enrol_users' => array(
'classname' => 'enrol_manual_external',
'methodname' => 'enrol_users',
'classname' => 'moodle_enrol_manual_external',
'methodname' => 'manual_enrol_users',
'classpath' => 'enrol/manual/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as enrol_manual_enrol_users()',
'capabilities'=> 'enrol/manual:enrol',
Expand Down
8 changes: 8 additions & 0 deletions enrol/manual/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,12 @@ public static function manual_enrol_users_returns() {
return enrol_manual_external::enrol_users_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function manual_enrol_users_is_deprecated() {
return true;
}
}
35 changes: 31 additions & 4 deletions files/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,18 @@ public static function get_files_parameters() {
* @param int $itemid
* @param string $filepath
* @param string $filename
* @param int $modified timestamp to return files changed after this time.
* @param string $contextlevel The context level for the file location.
* @param int $instanceid The instance id for where the file is located.
* @return array
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::get_files()
*/
public static function get_files($contextid, $component, $filearea, $itemid, $filepath, $filename) {
return core_files_external::get_files($contextid, $component, $filearea, $itemid, $filepath, $filename);
public static function get_files($contextid, $component, $filearea, $itemid, $filepath, $filename, $modified = null,
$contextlevel = null, $instanceid = null) {
return core_files_external::get_files($contextid, $component, $filearea, $itemid, $filepath, $filename,
$modified, $contextlevel, $instanceid);
}

/**
Expand All @@ -425,6 +430,15 @@ public static function get_files_returns() {
return core_files_external::get_files_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_files_is_deprecated() {
return true;
}

/**
* Returns description of upload parameters
*
Expand All @@ -447,13 +461,16 @@ public static function upload_parameters() {
* @param string $filepath
* @param string $filename
* @param string $filecontent
* @param string $contextlevel Context level (block, course, coursecat, system, user or module)
* @param int $instanceid Instance id of the item associated with the context level
* @return array
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::upload()
*/
public static function upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent) {
return core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
public static function upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent, $contextlevel, $instanceid) {
return core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename,
$filecontent, $contextlevel, $instanceid);
}

/**
Expand All @@ -467,4 +484,14 @@ public static function upload($contextid, $component, $filearea, $itemid, $filep
public static function upload_returns() {
return core_files_external::upload_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function upload_is_deprecated() {
return true;
}

}
10 changes: 9 additions & 1 deletion grade/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ public static function get_definitions_parameters() {
}

public static function get_definitions($cmids, $areaname, $activeonly = false) {
return core_grading_external::get_definitions($cmids, $areaname, $activeonly = false);
return core_grading_external::get_definitions($cmids, $areaname, $activeonly);
}

public static function get_definitions_returns() {
return core_grading_external::get_definitions_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_definitions_is_deprecated() {
return true;
}
}
64 changes: 62 additions & 2 deletions group/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,15 @@ public static function create_groups_returns() {
return core_group_external::create_groups_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function create_groups_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
*
Expand Down Expand Up @@ -1242,6 +1251,15 @@ public static function get_groups_returns() {
return core_group_external::get_groups_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_groups_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
*
Expand Down Expand Up @@ -1279,6 +1297,15 @@ public static function get_course_groups_returns() {
return core_group_external::get_course_groups_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_course_groups_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
*
Expand All @@ -1288,7 +1315,7 @@ public static function get_course_groups_returns() {
* @see core_group_external::delete_group_members_parameters()
*/
public static function delete_groups_parameters() {
return core_group_external::delete_group_members_parameters();
return core_group_external::delete_groups_parameters();
}

/**
Expand All @@ -1312,9 +1339,17 @@ public static function delete_groups($groupids) {
* @see core_group_external::delete_group_members_returns()
*/
public static function delete_groups_returns() {
return core_group_external::delete_group_members_returns();
return core_group_external::delete_groups_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function delete_groups_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
Expand Down Expand Up @@ -1353,6 +1388,14 @@ public static function get_groupmembers_returns() {
return core_group_external::get_group_members_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_groupmembers_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
Expand Down Expand Up @@ -1390,6 +1433,14 @@ public static function add_groupmembers_returns() {
return core_group_external::add_group_members_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function add_groupmembers_is_deprecated() {
return true;
}

/**
* Returns description of method parameters
Expand Down Expand Up @@ -1427,4 +1478,13 @@ public static function delete_groupmembers_returns() {
return core_group_external::delete_group_members_returns();
}

/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function delete_groupmembers_is_deprecated() {
return true;
}

}
Loading

0 comments on commit 3c1aa6f

Please sign in to comment.