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

Scheduled task manager does not properly handle timezones

    XMLWordPrintable

    Details

    • Testing Instructions:
      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
    • Workaround:
      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)
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull from Repository:
    • Sprint:
      Team Beards Sprint 9, Team Beards Sprint 10
    • Issue size:
      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

              • Votes:
                7 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Nov/15