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

Decimal comma & PHP8.0

    XMLWordPrintable

Details

    Description

      Hi there,
      I was testing Moodle on PHP8.0 and I've encountered a bug. Our language uses a decimal comma, and this can be by PHP interpreted as string. In PHP 8, as stated here, function round() no longer auto-typecast objects, and this can result in fatal error. One confirmed place is in the "Grade item" page (/grade/edit/tree/item.php). If a number with decimal comma is submitted, user gets following error:

      round(): Argument #1 ($num) must be of type int|float, string given
          line 1599 of /lib/gradelib.php: TypeError thrown
          line 1599 of /lib/gradelib.php: call to round()
          line 1612 of /lib/gradelib.php: call to grade_floatval()
          line 469 of /grade/edit/tree/item_form.php: call to grade_floats_different()
          line 653 of /lib/formslib.php: call to edit_item_form->validation()
          line 589 of /lib/formslib.php: call to moodleform->validate_defined_fields()
          line 699 of /lib/formslib.php: call to moodleform->is_validated()
          line 112 of /grade/edit/tree/item.php: call to moodleform->get_data()
      

      I would like to ask; has the compatibility of decimal commas been verified in PHP 8 in any way?
      For now, we'll just add typecasting in the code; but it would be good to fix this.

      Thank you for your response.
      Jarý Miroslav
      Moodle FEE CTU in Prague

      Attachments

        Issue Links

          Activity

            People

              stronk7 Eloy Lafuente (stronk7)
              jarymiro Miroslav Jarý
              Tim Hunt Tim Hunt
              Shamim Rezaie Shamim Rezaie
              CiBoT CiBoT
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days, 5 hours, 5 minutes
                  3d 5h 5m

                  Clockify

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