From: David Mudrak Date: Tue, 13 Apr 2010 06:22:57 +0000 (+0000) Subject: MDL-22015 Fixing get_string regression X-Git-Tag: v2.0.0-rc1~4225 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=d19e47031c643df2f6f9b55b1d4bb00fdfd2c779;hp=c7b9082a6afa84e0d90d3857c89c71d674bcc711 MDL-22015 Fixing get_string regression The passed $a placeholder object can be some advanced object like $USER for example. If such object contained other objects or arrays as properties, casting to string in the loop throws error. This patch just skips all arrays and objects when trying to find $a property value. Thanks to Sam H. for spotting this. --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b095c4ff354..105f1a65363 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5938,6 +5938,10 @@ class core_string_manager implements string_manager { // we do not support numeric keys - sorry! continue; } + if (is_object($value) or is_array($value)) { + // we support just string as value + continue; + } $search[] = '{$a->'.$key.'}'; $replace[] = (string)$value; }