Skip to content
Browse files

MDL-43175 events: Changed JSON encoding decoding comparison to be les…

…s 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.
  • Loading branch information...
1 parent ea04def commit 9a7713304c7b3f177d2936af7491a019122e32f1 @abgreeve abgreeve committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/classes/event/base.php
4 lib/classes/event/base.php
@@ -444,7 +444,9 @@ protected function get_legacy_logdata() {
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'])) {

0 comments on commit 9a77133

Please sign in to comment.
Something went wrong with that request. Please try again.