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
    • Resolution: Won't Do
    • Minor
    • None
    • 2.6.4, 2.7.1
    • 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
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.