From c16c1be700cee9da7789da375d1b5b417d7cfc76 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 24 Aug 2011 16:09:25 +0200 Subject: [PATCH] MDL-26796 accept objects that can be converted to string in clean_param() --- lib/moodlelib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 231d91721d7..f0b5b36b827 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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) {