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

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.10.1, 3.11, 4.0
    • Fix Version/s: 3.11
    • Component/s: Forms Library
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marina Marina Glancy
              Reporter:
              marina Marina Glancy
              Peer reviewer:
              Peter Dias Peter Dias
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/21

                  Time Tracking

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