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

Ability to force cron scheduled task definitions in config.php (schedule and disabled)

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MDL-65843-task-overrides
    • Hide

      1) Start with a clean moodle with all the default tasks schedules

      2) Add in some overrides to the config.php

      $CFG->scheduled_tasks = [
          '\assignfeedback_editpdf\task\convert_submissions' => [
              'schedule' => '*/15 * 1 2 3',
              'disabled' => 1,
          ],
          '\tool_dataprivacy\task\delete_existing_deleted_users' => [
              'schedule' => '0 1 2 3 5',
              'disabled' => 0,
          ],

          '\auth_db\task*users' => [
              'schedule' => '1 1 1 1 1',
              'disabled' => 0,
          ],
          '*' => [
              'schedule' => '2 2 2 2 2',
              'disabled' => 1,
          ],
      ];

      3) Visit the /admin/tool/task/scheduledtasks.php

      4) Confirm that you see 'Defined in config.php' for the overridden tasks

      5) Confirm that for the assignment task you see a yellow background on the schedule cells which differ from their defaults

      6) Confirm that the Data Privacy task which defaults to disabled is now enabled and you should see a valid time in the 'Next run' column

      7) Confirm that both overridden tasks have 'No' in the 'Default' column

      8) Confirm that an overridden task can not be edited by clicking on the cog

      9) Confirm that the task '\auth_db\task\sync_users' was matched by the wildcard override

      10) Confirm that the entire rest of the tasks are matched by the generic * wildcard

       

      Show
      1) Start with a clean moodle with all the default tasks schedules 2) Add in some overrides to the config.php $CFG->scheduled_tasks = [     '\assignfeedback_editpdf\task\convert_submissions' => [         'schedule' => '*/15 * 1 2 3',         'disabled' => 1,     ],     '\tool_dataprivacy\task\delete_existing_deleted_users' => [         'schedule' => '0 1 2 3 5',         'disabled' => 0,     ],     '\auth_db\task*users' => [         'schedule' => '1 1 1 1 1',         'disabled' => 0,     ],     '*' => [         'schedule' => '2 2 2 2 2',         'disabled' => 1,     ], ]; 3) Visit the /admin/tool/task/scheduledtasks.php 4) Confirm that you see 'Defined in config.php' for the overridden tasks 5) Confirm that for the assignment task you see a yellow background on the schedule cells which differ from their defaults 6) Confirm that the Data Privacy task which defaults to disabled is now enabled and you should see a valid time in the 'Next run' column 7) Confirm that both overridden tasks have 'No' in the 'Default' column 8) Confirm that an overridden task can not be edited by clicking on the cog 9) Confirm that the task '\auth_db\task\sync_users' was matched by the wildcard override 10) Confirm that the entire rest of the tasks are matched by the generic * wildcard  

    Description

      Most admin settings can be overridden in config.php but scheduled tasks cannot.

      Proposing something similar to $CFG->forced_plugin_settings like

       

      $CFG->forced_scheduled_tasks = array(
        "\tool_monitor\task\check_subscriptions" => array(
          "schedule" => "* * * * *",
          "disabled" => 1,
        ),
      );
      

       

      I think a single 'schedule' is nicer than having separate min, hour, day etc attributes.

      Attachments

        Issue Links

          Activity

            People

              jamie.stamp Jamie Stamp
              brendanheywood Brendan Heywood
              Brendan Heywood Brendan Heywood
              Adrian Greeve Adrian Greeve
              Michael Hawkins Michael Hawkins
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              5 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                17/May/21

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h