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

Deprecation of legacy cron

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Setup

      1. Make sure debugging is turned on. e.g. using MDK, run "mdk run mindev"

        Current core status

      2. Run cron a few times, (php admin/cli/cron.php | grep legacy)
      3. Verify that there isn't any "Use of legacy cron is deprecated" text in all the output of the cron runs.
      4. GREAT! That means that there aren't legacy uses in core.

      Force a legacy cron

      1. Edit mod/label/lib.php. And add these lines immediately after the <?php line:

        function label_cron() {
            echo "lalala" . PHP_EOL;
            return 1;
        }
        

      2. Save the file.
      3. With your favorite SQL editor, connect to the database and execute this command (the prefix "mdl_" may be different in your database):

        UPDATE mdl_modules SET cron = 1 where name = 'label'
        

      4. Run cron a few times, (php admin/cli/cron.php), wait more that 1 minute between runs at least once.
      5. Verify that, at very least you've got the "Use of legacy cron is deprecated" output once (it can happen more than once).
      6. Go to the zone where that output has happened.
      7. Verify that the output looks similar to this:

        Starting activity modules
        Processing module function label_cron ...
        lalala
        ++ Use of legacy cron is deprecated (label_cron). Please use scheduled tasks. ++
        * line 102 of /lib/classes/task/legacy_plugin_cron_task.php: call to debugging()
        * line 248 of /lib/cronlib.php: call to core\task\legacy_plugin_cron_task->execute()
        * line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        * line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        * line 79 of /admin/cli/cron.php: call to cron_run()
        

      8. GREAT! That means that legacy uses will be reported.
      Show
      Setup Make sure debugging is turned on. e.g. using MDK, run " mdk run mindev " Current core status Run cron a few times, ( php admin/cli/cron.php | grep legacy ) Verify that there isn't any "Use of legacy cron is deprecated" text in all the output of the cron runs. GREAT! That means that there aren't legacy uses in core. Force a legacy cron Edit mod/label/lib.php . And add these lines immediately after the <?php line: function label_cron() { echo "lalala" . PHP_EOL; return 1; } Save the file. With your favorite SQL editor, connect to the database and execute this command (the prefix "mdl_" may be different in your database): UPDATE mdl_modules SET cron = 1 where name = 'label' Run cron a few times, ( php admin/cli/cron.php ), wait more that 1 minute between runs at least once. Verify that, at very least you've got the "Use of legacy cron is deprecated" output once (it can happen more than once). Go to the zone where that output has happened. Verify that the output looks similar to this: Starting activity modules Processing module function label_cron ... lalala ++ Use of legacy cron is deprecated (label_cron). Please use scheduled tasks. ++ * line 102 of /lib/classes/task/legacy_plugin_cron_task.php: call to debugging() * line 248 of /lib/cronlib.php: call to core\task\legacy_plugin_cron_task->execute() * line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task() * line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks() * line 79 of /admin/cli/cron.php: call to cron_run() GREAT! That means that legacy uses will be reported.
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      In MDL-25499 we introduced the scheduled tasks system and making use of this system and moving away from legacy cron brings a lot of benefits (admin configurable times, tasks prevented from interfering with each other etc etc).

      We should eventually move away from legacy cron and deprecate that system in favour of everything using scheduled tasks.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              poltawski Dan Poltawski
              Peer reviewer:
              Simey Lameze
              Integrator:
              Jun Pataleta
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              11 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jun/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours, 10 minutes
                  5h 10m