MDL-22015 Fixing get_string regression
authorDavid Mudrak <david.mudrak@gmail.com>
Tue, 13 Apr 2010 06:22:57 +0000 (06:22 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Tue, 13 Apr 2010 06:22:57 +0000 (06:22 +0000)
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.

lib/moodlelib.php

index b095c4f..105f1a6 100644 (file)
@@ -5938,6 +5938,10 @@ class core_string_manager implements string_manager {
                         // we do not support numeric keys - sorry!
                         continue;
                     }
                         // 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;
                 }
                     $search[]  = '{$a->'.$key.'}';
                     $replace[] = (string)$value;
                 }