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

Cast both value and units to int for configduration write_setting

    XMLWordPrintable

Details

    Description

      The duration config type takes two values, a value and a unit.

      The unit is generally always something that can be cast to int.

      However, the value, which is provided by the user - might not be. If no value is entered, or a value which does not cast to an int - then php performs a string*string operation instead of int*int.

      For php before php8 - this simply resulted in a Warning - and the default validation was able to confirm it wasn't set correctly and prompt the user for a better value.

      From php8 however, string*string opts now raise a TypeError exception - so the user instead sees "Exception - Unsupported operand types: string * string".

       

      The fix for this is rather trivial - rather casting the result of u * v to an int, cast each value separately to an int before multiplying them.

      Attachments

        1. MDL-74886_master.mp4
          2.81 MB
        2. MDL-74886_v311.mp4
          3.03 MB
        3. MDL-74886_v400.mp4
          3.22 MB
        4. MDL-74886 error.png
          MDL-74886 error.png
          40 kB

        Activity

          People

            aolley Adam Olley
            aolley Adam Olley
            Simey Lameze Simey Lameze
            Jun Pataleta Jun Pataleta
            John Edward Pedregosa John Edward Pedregosa
            David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/Jul/22

              Time Tracking

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