Skip to content

Commit

Permalink
MDL-22015 Fixing get_string regression
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudrd8mz committed Apr 13, 2010
1 parent c7b9082 commit d19e470
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5938,6 +5938,10 @@ public function get_string($identifier, $component = '', $a = NULL) {
// 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;
}
Expand Down

0 comments on commit d19e470

Please sign in to comment.