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

fix_orphaned_question_categories.php --fix trigger an exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.1.6, 4.2.3
    • 4.1.3
    • Questions
    • MOODLE_401_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-79073-401
    • MDL-79073-402
    • Hide
      1. Log in as admin
      2. Create a course
      3. Add a quiz
        • Name: My quiz
      4. From quiz navigation, choose Question bank
      5. From Select a category choose Top for My quiz
      6. Create a new question, e.g. True/False
      7. From quiz navigation, choose Filters
        • Make a note of the ?contextid=<CONTEXTID> parameter in the URL
      8. Execute the following in your local DB (to simulate missing context)

        DELETE FROM moodle.m_context WHERE id = <CONTEXTID>;
        

      9. Execute the following:

        $ php admin/cli/fix_orphaned_question_categories.php --fix
        

      10. Confirm no exceptions were thrown
      11. Confirm debugging notice regarding question no longer linked to context is shown
      12. Confirm output ends with:

        Found and removed 1 orphaned question categories
        

      Show
      Log in as admin Create a course Add a quiz Name: My quiz From quiz navigation, choose Question bank From Select a category choose Top for My quiz Create a new question, e.g. True/False From quiz navigation, choose Filters Make a note of the ?contextid=<CONTEXTID> parameter in the URL Execute the following in your local DB (to simulate missing context) DELETE FROM moodle.m_context WHERE id = <CONTEXTID>; Execute the following: $ php admin/cli/fix_orphaned_question_categories.php --fix Confirm no exceptions were thrown Confirm debugging notice regarding question no longer linked to context is shown Confirm output ends with: Found and removed 1 orphaned question categories

      I tried to execute this following command line:

      php admin/cli/fix_orphaned_question_categories.php --fix 

      And I had this result:

      php admin/cli/fix_orphaned_question_categories.php --fix
      == Checking for orphaned categories ==
      Found orphaned category: Défaut pour Examen hors-ligne 2 questions lames (test)
      Cleaning...!!! Impossible de trouver l'enregistrement de données dans la table context de la base de données. !!!
      !! SELECT * FROM {context} WHERE id = ?
      [array (
        0 =&gt; '6930045',
      )]
      Error code: invalidrecord !!
      !! Stack trace: * line 1654 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
      * line 1630 of /lib/dml/moodle_database.php: call to moodle_database-&gt;get_record_select()
      * line 5429 of /lib/accesslib.php: call to moodle_database-&gt;get_record()
      * line 221 of /lib/classes/event/base.php: call to context::instance_by_id()
      * line 125 of /lib/classes/event/question_base.php: call to core\event\base::create()
      * line 418 of /lib/questionlib.php: call to core\event\question_base::create_from_question_instance()
      * line 246 of /lib/questionlib.php: call to question_delete_question()
      * line 88 of /admin/cli/fix_orphaned_question_categories.php: call to question_category_delete_safe()
       !!  

            pholden Paul Holden
            Gurvan Gurvan Giboire
            Tim Hunt Tim Hunt
            Andrew Lyons Andrew Lyons
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 16 minutes
                1h 16m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.