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

Run individual scheduled tasks from web

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1. Go to the scheduled tasks page
      EXPECTED: There should be a 'Run now' button (looks like a link) for all the tasks except the disabled ones.
      2. Click the 'Run now' button for a scheduled task.
      EXPECTED: It should run the task, showing the same display as it would when it runs as part of normal cron.
      3. Use this to run a long-running scheduled task, such as 'Update all installed language packs' or 'Legacy cron processing for plugins'.
      EXPECTED: While the task runs, you should see its output appear progressively (i.e. not all at once). [Note: If your system is super fast it might be hard to tell...]
      4. Open a second browser so that you have two user sessions. Get both browsers in a position to run the same (long-running) scheduled task. Run the task very quickly from both browsers so that one is trying to start the task while the other is continuing it.
      EXPECTED: The task should run in the first browser, but in the second you should see the following debug information instead of of the task output: "Unable to get task lock for [task class]."

      With regard to step 3 about showing progress during the task:

      a. It may be useful to check in multiple Moodle themes - the behaviour of 'clean' vs 'boost' is different, although I've got both working now I believe!
      b. There might be some browsers that won't display the page progressively even when we do output it progressively. I've confirmed that Chrome, Firefox, and Internet Explorer 11 running on Windows 7 all work for me, but I know we've seen problems in the past with some configurations.

      Show
      1. Go to the scheduled tasks page EXPECTED: There should be a 'Run now' button (looks like a link) for all the tasks except the disabled ones. 2. Click the 'Run now' button for a scheduled task. EXPECTED: It should run the task, showing the same display as it would when it runs as part of normal cron. 3. Use this to run a long-running scheduled task, such as 'Update all installed language packs' or 'Legacy cron processing for plugins'. EXPECTED: While the task runs, you should see its output appear progressively (i.e. not all at once). [Note: If your system is super fast it might be hard to tell...] 4. Open a second browser so that you have two user sessions. Get both browsers in a position to run the same (long-running) scheduled task. Run the task very quickly from both browsers so that one is trying to start the task while the other is continuing it. EXPECTED: The task should run in the first browser, but in the second you should see the following debug information instead of of the task output: "Unable to get task lock for [task class] ." With regard to step 3 about showing progress during the task: a. It may be useful to check in multiple Moodle themes - the behaviour of 'clean' vs 'boost' is different, although I've got both working now I believe! b. There might be some browsers that won't display the page progressively even when we do output it progressively. I've confirmed that Chrome, Firefox, and Internet Explorer 11 running on Windows 7 all work for me, but I know we've seen problems in the past with some configurations.
    • Affected Branches:
      MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull Master Branch:
      MDL-55980-master

      Description

      This came up in discussions on MDL-53110 and MDL-55117, separating from these issues because it's not about behat any more.

      This is a proposal to allow executing individual scheduled tasks from web interface. We already have the CLI command for it:

      php admin/tool/task/cli/schedule_task.php --execute=\\some\\task
      

      This issue suggests to add a web version:

      http://yourmoodlesite/admin/cron.php?task=\some\task
      

      Discussion on security of this call can be found on MDL-53110, the summary is:

      • this call will ignore next run time and execute given scheduled task always (without any other tasks)
      • display a link in the scheduled tasks overview page for each task: "Run now"
      • require user requesting the page to be logged in and have appropriate capability
      • ignore cronclionly and cronremotepassword but require session key

      (If run inside behat test - do not require capabilities and sesskey)

      P.S. If it's easier to implement, this can be new script /admin/schedule_task.php and not /admin/cron.php

        Attachments

        1. examplerun.png
          examplerun.png
          26 kB
        2. tasklist.png
          tasklist.png
          72 kB
        3. confirmscreen.png
          confirmscreen.png
          19 kB

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

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