From 98dece220bdfc095fac5434a434ed8579fa8fa96 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Wed, 3 Sep 2014 22:26:40 +0200 Subject: [PATCH] MDL-46588 web services: Fixed invalid check of empty contextid in function get_context_from_params --- lib/externallib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/externallib.php b/lib/externallib.php index 2ce6de661fc..95039eecf0c 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -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']);