Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-46701

Base event JSON encoding decoding check can fail for any float values.

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.6.4, 2.7.1
    • BACKEND
    • Events API
    • MOODLE_26_STABLE, MOODLE_27_STABLE

    Description

      In MDL-43175, the comparison of event data with its decoded equivalent was relaxed so that floats which happened to be whole numbers would not throw unwanted debugging messages, but this comparison can fail for any float.

      To replicate, add the following to lib/tests/event_test.php in the test_problematic_events() function:

      // Check that other float numbers do not trigger debugging messages.
              $event8 = \core_tests\event\unittest_executed::create(array('courseid'=>1, 'context'=>\context_system::instance(),
                      'other' => array('starttime' => microtime(true), 'wholenumber' => 90.0000, 'numberwithdecimals' => 54.7656, 'sample' => 1)));
              $event8->trigger();
              $this->assertDebuggingNotCalled();
      

      The PHP documentation says "do not compare floating point numbers directly for equality" (http://php.net/manual/en/language.types.float.php)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              maherne Michael Aherne
              David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: