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

PHP 8.0: getdate(null) returns current date instead of Jan 1st 1970 as it is in php7

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.11
    • 3.10.1, 3.11, 4.0
    • Forms Library

      The original description of this issue has been modified. Initially it was reported as an error in the dateselector field which is actually part of MDL-70966

      This issue has been re-purposed for another problem discovered in the process:

      getdate(null)
      

      returns different results in PHP8 and PHP7. Since Moodle supports both php7 and php8 we need to make sure that usergetdate() is never called with the null argument because the behavior will be inconsistent.

      To see the differences, take a look to https://3v4l.org/PeZhr

      Summary:

      • Not passing anything is consistent, returns now (2021).
      • Passing zero (0) is consistent, returns 0 (1970)
      • Passing null is inconsistent, with php7 it returns 0, but with php8, it returns now.

      Hence:

      • We must prevent any (inconsistent) call passing null to happen (that's what the 1st commit does, detect).
      • We must change any call previously passing null, to pass 0, to keep results the same. 2nd commit will do.

            marina Marina Glancy
            marina Marina Glancy
            Peter Dias Peter Dias
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 40 minutes
                1d 40m

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