From 49ff13422763a9ebcd8807ff73feb7cd329ce8b8 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Wed, 4 Dec 2013 15:27:35 +0800 Subject: [PATCH] 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. --- lib/classes/event/base.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/classes/event/base.php b/lib/classes/event/base.php index 6a303f2cd6e..60884069fd1 100644 --- a/lib/classes/event/base.php +++ b/lib/classes/event/base.php @@ -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'])) {