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

Notices or misconfiguration can happen when upgrading or restoring quiz_results block

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a fresh 2.8 instance
      2. Add 3 instances of the quiz_results block to the course page (A, B, K)
      3. Leave A unconfigured, do not touch it
      4. Edit B and click save without selecting a quiz
      5. Edit K and click save without selecting a quiz
      6. Update the encoded configdata of K from mdl_block_instances to remove the quizid and gradeformat.

        <?php
        $data = "DATAHERE";
        $obj = unserialize(base64_decode($data));
        unset($obj->quizid);
        unset($obj->gradeformat);
        echo base64_encode(serialize($obj)) . PHP_EOL;
        

      7. Add 2 quizzes to the course
      8. Add 2 more instances of the quiz_results block to the course page (C, D)
      9. Edit C, select the 1st quiz and save
      10. Edit D, select the 2nd quiz, change all the values in the form, and save
      11. Delete the 2nd quiz
      12. Go to the remaining quiz and add a quiz_results block there (E), edit it and Save
      13. As a student, take the quiz
      14. At this point, as admin, only the block C and E should not warn about missing config
      15. Backup the course
      16. Upgrade to the latest 2.9
      17. Confirm that you do not see any error throughout the process
      18. Confirm that the blocks are identical as they were before:
        • C and E are still displaying the quiz results
        • A, B, K and D are displaying the same message
        • D has kept its customised settings
      19. Also confirm that each of the blocks are instances of activity_results (mdl_block_instances)
      20. Restore the backup you made as a new course
      21. Confirm that you do not see any error throughout the process
      22. Confirm that the blocks are identical as they were before:
        • C and E are still displaying the quiz results
        • A, B, K and D are displaying the same message
        • D has kept its customised settings
      23. Also confirm that each of the blocks are instances of activity_results (mdl_block_instances)
      Show
      Create a fresh 2.8 instance Add 3 instances of the quiz_results block to the course page (A, B, K) Leave A unconfigured, do not touch it Edit B and click save without selecting a quiz Edit K and click save without selecting a quiz Update the encoded configdata of K from mdl_block_instances to remove the quizid and gradeformat. <?php $data = "DATAHERE"; $obj = unserialize(base64_decode($data)); unset($obj->quizid); unset($obj->gradeformat); echo base64_encode(serialize($obj)) . PHP_EOL; Add 2 quizzes to the course Add 2 more instances of the quiz_results block to the course page (C, D) Edit C, select the 1st quiz and save Edit D, select the 2nd quiz, change all the values in the form, and save Delete the 2nd quiz Go to the remaining quiz and add a quiz_results block there (E), edit it and Save As a student, take the quiz At this point, as admin, only the block C and E should not warn about missing config Backup the course Upgrade to the latest 2.9 Confirm that you do not see any error throughout the process Confirm that the blocks are identical as they were before: C and E are still displaying the quiz results A, B, K and D are displaying the same message D has kept its customised settings Also confirm that each of the blocks are instances of activity_results (mdl_block_instances) Restore the backup you made as a new course Confirm that you do not see any error throughout the process Confirm that the blocks are identical as they were before: C and E are still displaying the quiz results A, B, K and D are displaying the same message D has kept its customised settings Also confirm that each of the blocks are instances of activity_results (mdl_block_instances)
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50047-master-2nd

      Description

      When upgrading moodle.org, we got the following notices:

      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
       
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line
       71
      PHP Notice:  Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      Notice: Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on lin
      e 57
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line
       71
      PHP Notice:  Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      Notice: Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      PHP Notice:  Undefined property: stdClass::$gradeformat in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 60
       
      Notice: Undefined property: stdClass::$gradeformat in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 60
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
       
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      PHP Notice:  Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
       
      Notice: Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
       
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      PHP Notice:  Undefined property: object::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
       
      Notice: Undefined property: stdClass::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
       
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      PHP Notice:  Undefined property: object::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
       
      Notice: Undefined property: object::$quizid in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 57
      PHP Notice:  Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
       
      Notice: Trying to get property of non-object in /var/www/vhosts/moodle.org/html/blocks/quiz_results/db/upgrade.php on line 71
      
      

      (Note that we've noticed quiz-related inconsistencies in the past, but it'd be great if the upgrade was silent).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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