MDL-43175 events: Changed JSON encoding decoding comparison to be less strict.

Debugging messages would be sent when other contained a float that is a whole number.
When encoding and decoding using JSON the number is changed to an integer and the
comparison fails.
This commit is contained in:
Adrian Greeve
2013-12-09 09:21:37 +08:00
parent c36a2401ab
commit 49ff134227
+3 -1
View File
@@ -444,7 +444,9 @@ abstract class base implements \IteratorAggregate {
debugging('Number of event data fields must not be changed in event classes', DEBUG_DEVELOPER);
}
$encoded = json_encode($this->data['other']);
if ($encoded === false or $this->data['other'] !== json_decode($encoded, true)) {
// The comparison here is not set to strict as whole float numbers will be converted to integers through JSON encoding /
// decoding and send an unwanted debugging message.
if ($encoded === false or $this->data['other'] != json_decode($encoded, true)) {
debugging('other event data must be compatible with json encoding', DEBUG_DEVELOPER);
}
if ($this->data['userid'] and !is_number($this->data['userid'])) {