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

Scheduled tasks of mod plugins can not be uninstalled

    XMLWordPrintable

Details

    • MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • MDL-54892-master
    • Hide

      Remove the entry within the database table "mdl_task_schedule" manually.

      Show
      Remove the entry within the database table "mdl_task_schedule" manually.
    • Hide
      Testing deletion of plugins with scheduled tasks
      1. Install a module which defines a task_scheduled e.g. https://moodle.org/plugins/mod_ratingallocate or https://moodle.org/plugins/mod_questionnaire (forum is the only one in core and it can't be removed)
      2. Goto administration ► Server ► Scheduled tasks
        • Assert there is at least one scheduled tasks installed for the module.
      3. Uninstall the module
      4. Goto administration ► Server ► Scheduled tasks
        • Assert there is no scheduled tasks installed for the module.
      Testing deletion of plugins with message handlers

      (You'll need an email server that allows IMAP and SMTP connections. We'll use the mod_forum for our tests since it's got inbound message handling.)

      1. Set up outbound email settings: Site administration ► Plugins ► Message outputs ► Email
      2. Set up inbound email settings: Site administration ► Server ► Incoming mail configuration ► Mail settings
      3. Go to Site administration ► Server ► Incoming mail configuration ► Message handlers
      4. Set Reply to forum posts to Yes.
      5. Check the mdl_messageinbound_handlers table in the database.
        • Confirm that there is a record for mod_forum.
      6. Create a course.
      7. Enrol some users with valid emails.
      8. Create a Single simple discussion forum and set its Subscription mode to Forced subscription.
      9. Post a reply to the discussion. Make sure to tick Send forum post notifications with no editing-time delay.
      10. On a terminal, go to your moodle root directory and run the following command:

        php admin/cli/cron.php
        

      11. Check the mdl_messageinbound_datakeys table in the database.
        • Confirm that a key has been added.
      12. Edit the is_uninstall_allowed() function in /lib/classes/plugininfo/mod.php and replace its contents with just

        return true;
        

      13. Go to Site administration ► Plugins ► Plugins overview.
      14. Uninstall the following in the given order:
        • block_news_items
        • block_search_forums
        • mod_forum
      15. Check the mdl_messageinbound_handlers table in the database.
        • Confirm that the record for mod_forum has been removed.
      16. Check the mdl_messageinbound_datakeys table in the database.
        • Confirm that the key that has been added has now been removed.
      Show
      Testing deletion of plugins with scheduled tasks Install a module which defines a task_scheduled e.g. https://moodle.org/plugins/mod_ratingallocate or https://moodle.org/plugins/mod_questionnaire (forum is the only one in core and it can't be removed) Goto administration ► Server ► Scheduled tasks Assert there is at least one scheduled tasks installed for the module. Uninstall the module Goto administration ► Server ► Scheduled tasks Assert there is no scheduled tasks installed for the module. Testing deletion of plugins with message handlers (You'll need an email server that allows IMAP and SMTP connections. We'll use the mod_forum for our tests since it's got inbound message handling.) Set up outbound email settings: Site administration ► Plugins ► Message outputs ► Email Set up inbound email settings: Site administration ► Server ► Incoming mail configuration ► Mail settings Go to Site administration ► Server ► Incoming mail configuration ► Message handlers Set Reply to forum posts to Yes . Check the mdl_messageinbound_handlers table in the database. Confirm that there is a record for mod_forum . Create a course. Enrol some users with valid emails. Create a Single simple discussion forum and set its Subscription mode to Forced subscription . Post a reply to the discussion. Make sure to tick Send forum post notifications with no editing-time delay . On a terminal, go to your moodle root directory and run the following command: php admin/cli/cron.php Check the mdl_messageinbound_datakeys table in the database. Confirm that a key has been added. Edit the is_uninstall_allowed() function in /lib/classes/plugininfo/mod.php and replace its contents with just return true; Go to Site administration ► Plugins ► Plugins overview . Uninstall the following in the given order: block_news_items block_search_forums mod_forum Check the mdl_messageinbound_handlers table in the database. Confirm that the record for mod_forum has been removed. Check the mdl_messageinbound_datakeys table in the database. Confirm that the key that has been added has now been removed.

    Description

      Scheduled tasks for mod plugins are registered with their component name using the frankenstyle syntax.
      See lib/classes/task/manager.php:reset_scheduled_tasks_for_component()
      However, for the uninstall process of a plugin (in case of 'mod's) the $pluginname is abreviated to no longer contain the prefix 'mod_'.
      See lib/adminlib.php:151

      In this way, the delete_records in lib/adminlib.php:203 is not able to delete the tasks of the module.

      Same is valid for the entries of 'messageinbound_datakeys' and 'messageinbound_handlers'.

      Attachments

        Activity

          People

            tobias.reischmann Tobias Reischmann
            tobias.reischmann Tobias Reischmann
            Jun Pataleta Jun Pataleta
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Damyon Wiese Damyon Wiese
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              12/Sep/16