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

Be able to force cron scheduled task definitions in config.php ie schedule and disabled

    XMLWordPrintable

    Details

    • Testing Instructions:
      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  
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull Master Branch:
      MDL-65843-task-overrides

      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

              Assignee:
              jamie.stamp Jamie Stamp
              Reporter:
              brendanheywood Brendan Heywood
              Peer reviewer:
              Brendan Heywood
              Integrator:
              Adrian Greeve
              Tester:
              Michael Hawkins
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              5 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

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

                  Time Tracking

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