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

Orphaned top categories not removed correctly on delete

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Before this patch has been applied
      1. Log in as admin and create a course
      2. Add a quiz in the course. Name the quiz "Quiz1".
      3. Go to the quiz's editing page and create a true/false question in the quiz. In the question's editing page, set the category of the question to "Default for Quiz1"
      4. Now go to the course's main page and delete the Quiz1
      5. Run cron and wait for it to finish its job
      6. Execute the following query on DB
        1. Verify that it returns at least one row (probably at least two)
          (this verifies the presence of the bug)
          Note: Replace mdl_ with the correct DB prefix if yours is different

      SELECT qc1.*
      FROM mdl_question_categories qc1
      JOIN mdl_question_categories qc2
      ON qc1.contextid = qc2.contextid AND qc1.id <> qc2.id
      WHERE qc1.parent = 0 AND qc2.parent = 0;
      

      Testing
      1. Apply the patch in this issue
      2. Run the upgrade
      3. Re-run the SQL query
        1. Verify that it now returns no results
      Show
      Before this patch has been applied Log in as admin and create a course Add a quiz in the course. Name the quiz "Quiz1". Go to the quiz's editing page and create a true/false question in the quiz. In the question's editing page, set the category of the question to "Default for Quiz1" Now go to the course's main page and delete the Quiz1 Run cron and wait for it to finish its job Execute the following query on DB Verify that it returns at least one row (probably at least two) (this verifies the presence of the bug) Note: Replace mdl_ with the correct DB prefix if yours is different SELECT qc1.* FROM mdl_question_categories qc1 JOIN mdl_question_categories qc2 ON qc1.contextid = qc2.contextid AND qc1.id <> qc2.id WHERE qc1.parent = 0 AND qc2.parent = 0; Testing Apply the patch in this issue Run the upgrade Re-run the SQL query Verify that it now returns no results
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-62897-master

      Description

      When trying to restore a course I get the following error with no way of going forward:

       

      Invalid get_string() identifier: 'restoremultipletopcats' or component 'questions'. Perhaps you are missing $string['restoremultipletopcats'] = ''; in mod/questions/lang/en/questions.php?
      line 349 of /lib/classes/string_manager_standard.php: call to debugging()
      line 7089 of /lib/moodlelib.php: call to core_string_manager_standard->get_string()
      line 721 of /backup/util/dbops/restore_dbops.class.php: call to get_string()
      line 520 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level()
      line 178 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions()
      line 382 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks()
      line 992 of /backup/util/ui/restore_ui_stage.class.php: call to restore_controller->execute_precheck()
      line 372 of /backup/util/ui/restore_ui.class.php: call to restore_ui_stage_process->process()
      line 123 of /backup/restore.php: call to restore_ui->requires_substage()
      

      I checked out the question bank for this quiz.  And it does have multiple TOP categories.  But I have no way to delete the extra ones as when I look in category management, the extra ones do not show.

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/18