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

Replace custom Moodle timezone stuff with standard PHP date/time code

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. run phpunit
      2. run behat
      3. try fresh new install - you will be prompted to select a timezone now
      4. try upgrade - nothing should change, numeric and timezones not supported by OS are displayed as "invalid", 99 is "automatically" migrated to real default timezone
      5. try edit own profile - you should see what the server timezone actually is
      6. try editing of other users
      7. test anything related to timezones

      Dan added exploratory test:

      1. Try a few different installs on 2.8 with various timezone settings in server value and user values - and make sure upgrade behaves as expected.
      Show
      run phpunit run behat try fresh new install - you will be prompted to select a timezone now try upgrade - nothing should change, numeric and timezones not supported by OS are displayed as "invalid", 99 is "automatically" migrated to real default timezone try edit own profile - you should see what the server timezone actually is try editing of other users test anything related to timezones Dan added exploratory test: Try a few different installs on 2.8 with various timezone settings in server value and user values - and make sure upgrade behaves as expected.
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip_MDL-49684_m29_tz2

      Description

      Moodle timezone stuff is buggy, unreliable and hard to use. Moreover it is incompatible with standard PHP date functions and classes.

      Pretty much all places that use $CFG->timezone and $user->timezone directly (outside of admin settings and user profiles) are bugs at the moment, this patch introduces new core_date::get_system_timezone() and core_date::get_user_timezone($user = null) which return timezone name compatible both with Moodle legacy date functions and standard PHP code.

      Backwards compatibility should be excellent both for data and existing code.

      Remaining issues that are not solved by this patch:

      • the badzone list could be expanded to cover all those strange Windows timezones and maybe some more abbreviations
      • some parts of Moodle need to be properly cleaned up/rewritten to use PHP time intervals - stats, calendar, etc.
      • 3rd party calendars need to be updated
      • there should be some simple docs for developers
      • there could be an environment check for outdated PHP timezones - if older than 1 year for example

      Required documentation:

      • developers - they need to understand the new core_date class and they need to use it always
      • administrators should know that the built-in timezone data can be updated via pecl extension - see http://pecl.php.net/package/timezonedb

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                21 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/May/15