MDL-46588 web services: Fixed invalid check of empty contextid in function get_context_from_params

This commit is contained in:
Juan Leyva
2014-09-12 11:25:16 +02:00
parent 482abd0f70
commit 98dece220b
+2 -2
View File
@@ -377,9 +377,9 @@ class external_api {
*/
protected static function get_context_from_params($param) {
$levels = context_helper::get_all_levels();
if (isset($param['contextid'])) {
if (!empty($param['contextid'])) {
return context::instance_by_id($param['contextid'], IGNORE_MISSING);
} else if (isset($param['contextlevel']) && isset($param['instanceid'])) {
} else if (!empty($param['contextlevel']) && !empty($param['instanceid'])) {
$contextlevel = "context_".$param['contextlevel'];
if (!array_search($contextlevel, $levels)) {
throw new invalid_parameter_exception('Invalid context level = '.$param['contextlevel']);