MDL-26796 accept objects that can be converted to string in clean_param()

This commit is contained in:
Petr Skoda 2011-08-24 16:09:25 +02:00
parent ebdeccca4e
commit c16c1be700

View File

@ -685,8 +685,14 @@ function clean_param($param, $type) {
global $CFG;
if (is_object($param) or is_array($param)) {
throw new coding_exception('clean_param() can not process objects or arrays, please use clean_param_array() instead.');
if (is_array($param)) {
throw new coding_exception('clean_param() can not process arrays, please use clean_param_array() instead.');
} else if (is_object($param)) {
if (method_exists($param, '__toString')) {
$param = $param->__toString();
} else {
throw new coding_exception('clean_param() can not process objects, please use clean_param_array() instead.');
}
}
switch ($type) {