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

Scheduled task manager does not properly handle timezones

    XMLWordPrintable

Details

    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_28_STABLE
    • Hide

      In the Moodle administration, change your "Default timezone" settings from UTC-X (in my case UTC-5) to a location (in my case America/New-York)

      Show
      In the Moodle administration, change your "Default timezone" settings from UTC-X (in my case UTC-5) to a location (in my case America/New-York)
    • Hide
      1. Change your moodle default timezone to a UTC timezone (e.g. UTC-6 or UTC+8)
      2. Run Cron php admin/cli/cron.php or go to admin/cron.php
      3. You should see error message "You are using a nonexistent time zone. Please update your timezones and choose a location. See https://docs.moodle.org/28/en/Location" but the cron should run successfully
      4. Go to "Site administration ► Location ► Update timezones" and update your timezones
      5. Change your timezone to a location e.g. "Australia/Perth" or "America/New-York"
      6. Run cron
      7. You should not see the nonexistent time zone error message.
      8. Change your timezone to "Server's local time"
      9. Run cron
      10. You should not see the error
      Show
      Change your moodle default timezone to a UTC timezone (e.g. UTC-6 or UTC+8) Run Cron php admin/cli/cron.php or go to admin/cron.php You should see error message "You are using a nonexistent time zone. Please update your timezones and choose a location. See https://docs.moodle.org/28/en/Location " but the cron should run successfully Go to "Site administration ► Location ► Update timezones" and update your timezones Change your timezone to a location e.g. "Australia/Perth" or "America/New-York" Run cron You should not see the nonexistent time zone error message. Change your timezone to "Server's local time" Run cron You should not see the error
    • Team Beards Sprint 9, Team Beards Sprint 10
    • Medium

    Description

      I ran the Web cron and this came up:

      Notice: date_default_timezone_set(): Timezone ID '-13.0' is invalid in /home/fred/www/repositories/sm/moodle/lib/classes/task/scheduled_task.php on line 302
       
      Call Stack:
          0.0001     241752   1. {main}() /home/fred/www/repositories/sm/moodle/admin/cron.php:0
          0.0960   15719720   2. cron_run() /home/fred/www/repositories/sm/moodle/admin/cron.php:81
          1.4107   25761776   3. core\task\manager::scheduled_task_complete() /home/fred/www/repositories/sm/moodle/lib/cronlib.php:79
          1.4114   25765176   4. core\task\scheduled_task->get_next_scheduled_time() /home/fred/www/repositories/sm/moodle/lib/classes/task/manager.php:589
          1.4115   25778000   5. date_default_timezone_set() /home/fred/www/repositories/sm/moodle/lib/classes/task/scheduled_task.php:302
      

      Coming from:

              if (!empty($CFG->timezone) && $CFG->timezone != 99) {
                  date_default_timezone_set($CFG->timezone);
              }
      

      Unfortunately, the setting timezone is not compatible with date_default_timezone_set. I do not know the implications of this, but I suspect that this would lead to random tasks executions.

      Attachments

        Issue Links

          Activity

            People

              johno John Okely
              fred Frédéric Massart
              Damyon Wiese Damyon Wiese
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Simey Lameze Simey Lameze
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              7 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Nov/15