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

Error while restoring backup into a new course

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.6, 2.2.3, 2.3
    • Fix Version/s: 2.1.7, 2.2.4
    • Component/s: Backup, Gradebook
    • Labels:
    • Testing Instructions:
      Hide
      1. Log in as admin
      2. restore attached course backup (backup-moodle2-course-itc1-20120531-2114-modified.mbz) in new course
      3. Make sure you don't encounter any error and course should restore.(Note: you will get debug notice like "Mapped user id not found for grade item id '54'")
      4. 2 users are shown as participants ("sam student" and "teacher tom").
      Show
      Log in as admin restore attached course backup (backup-moodle2-course-itc1-20120531-2114-modified.mbz) in new course Make sure you don't encounter any error and course should restore.(Note: you will get debug notice like "Mapped user id not found for grade item id '54'") 2 users are shown as participants ("sam student" and "teacher tom").
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      wip-mdl-33455

      Description

      Got the following error while restoring a backup into a new course. lol @ "Will be implemented before 2.0 release"

      Error writing to database

      More information about this error
      Debug info: Column 'userid' cannot be null
      INSERT INTO mdl_grade_grades (userid,rawgrade,rawgrademax,rawgrademin,rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported,overridden,excluded,feedback,feedbackformat,information,informationformat,timecreated,timemodified,itemid) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
      [array (
      0 => NULL,
      1 => NULL,
      2 => '100.00000',
      3 => '0.00000',
      4 => NULL,
      5 => NULL,
      6 => NULL,
      7 => '0',
      8 => '0',
      9 => '0',
      10 => '0',
      11 => '0',
      12 => '0',
      13 => NULL,
      14 => '0',
      15 => NULL,
      16 => '0',
      17 => NULL,
      18 => NULL,
      19 => '17',
      )]
      Error code: dmlwriteexception
      Stack trace:

      line 416 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 952 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 994 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      line 222 of /backup/moodle2/restore_stepslib.php: call to mysqli_native_moodle_database->insert_record()
      line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->process_grade_grade()
      line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
      line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
      line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
      line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
      line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
      line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
      line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
      line ? of unknownfile: call to progressive_parser->end_tag()
      line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
      line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
      line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
      line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
      line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
      line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
      line 46 of /backup/restore.php: call to restore_ui->execute()

      Output buffer: <div class="notifytiny">Skipping 'database' enrolment plugin. Will be implemented before 2.0 release<ul style="text-align: left"><li>line 1496 of /backup/moodle2/restore_stepslib.php: call to debugging()</li><li>line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_enrolments_structure_step->process_enrol()</li><li>line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()</li><li>line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()</li><li>line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()</li><li>line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()</li><li>line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()</li><li>line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()</li><li>line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()</li><li>line ? of unknownfile: call to progressive_parser->end_tag()</li><li>line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()</li><li>line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()</li><li>line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()</li><li>line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()</li><li>line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()</li><li>line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()</li><li>line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()</li><li>line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()</li><li>line 46 of /backup/restore.php: call to restore_ui->execute()</li></ul></div>

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              andyjdavis Andrew Davis added a comment -

              Attaching the backup file.

              Show
              andyjdavis Andrew Davis added a comment - Attaching the backup file.
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks for reporting this Andrew.

              This is happening because gradebook.xml has a grade for userid= 1 (<userid>1</userid>)
              In user.xml there is no information about userid=1

              As part of MDL-26572 fix, return value for userid was made NULL, whereas it should be integer and not null (according to db schema). Hence this error was coming.

              Can you please review my patch and suggest if my approach is correct. I am assuming, if user information is not found, then there is no need to insert grade. Not sure if we should throw error/notice at this point.

              Any input is appreciated

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks for reporting this Andrew. This is happening because gradebook.xml has a grade for userid= 1 (<userid>1</userid>) In user.xml there is no information about userid=1 As part of MDL-26572 fix, return value for userid was made NULL, whereas it should be integer and not null (according to db schema). Hence this error was coming. Can you please review my patch and suggest if my approach is correct. I am assuming, if user information is not found, then there is no need to insert grade. Not sure if we should throw error/notice at this point. Any input is appreciated
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Adding Andrew as peer-reviewer.

              Show
              rajeshtaneja Rajesh Taneja added a comment - Adding Andrew as peer-reviewer.
              Hide
              andyjdavis Andrew Davis added a comment -

              I have a user with ID 1 in my database. It's guest, who I dont think should even be able to have grades. I've raised MDL-33505. I'll investigate how on earth that's happening.

              The safety check you've added is fine. Putting up a debugging() notice is probably a good idea. Ideally it would contain the grade item ID and the user ID from the backup file.

              Show
              andyjdavis Andrew Davis added a comment - I have a user with ID 1 in my database. It's guest, who I dont think should even be able to have grades. I've raised MDL-33505 . I'll investigate how on earth that's happening. The safety check you've added is fine. Putting up a debugging() notice is probably a good idea. Ideally it would contain the grade item ID and the user ID from the backup file.
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks Andrew,

              I have added debug message. Can you please confirm, if this is fine.

              IMO it can be back-ported as well, what do you recommend ?

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks Andrew, I have added debug message. Can you please confirm, if this is fine. IMO it can be back-ported as well, what do you recommend ?
              Hide
              andyjdavis Andrew Davis added a comment -

              Code looks good. Back porting is probably a good idea. You'll also want to amend the testing instructions to explain that the tester will get a debugging message.

              Show
              andyjdavis Andrew Davis added a comment - Code looks good. Back porting is probably a good idea. You'll also want to amend the testing instructions to explain that the tester will get a debugging message.
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks Andrew.

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks Andrew.
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Attaching modified backup-file for testing, as original contains admin user.

              Show
              rajeshtaneja Rajesh Taneja added a comment - Attaching modified backup-file for testing, as original contains admin user.
              Hide
              nebgor Aparup Banerjee added a comment -

              Thanks, this has been integrated into master.

              Andrew: i've commented on your issue, the guest user should have read access only.

              Show
              nebgor Aparup Banerjee added a comment - Thanks, this has been integrated into master. Andrew: i've commented on your issue, the guest user should have read access only.
              Hide
              salvetore Michael de Raadt added a comment -

              Test result: Not successful

              I wasn't sure if you meant to restore the backup as a new course or to restore into a newly created course. I tried both and both failed. The error mentioned in the testing instructions and the one shown in the description both came up at the "Process" stage. The restore did not complete and no course data was restored.

              Show
              salvetore Michael de Raadt added a comment - Test result: Not successful I wasn't sure if you meant to restore the backup as a new course or to restore into a newly created course. I tried both and both failed. The error mentioned in the testing instructions and the one shown in the description both came up at the "Process" stage. The restore did not complete and no course data was restored.
              Hide
              poltawski Dan Poltawski added a comment -

              I think Michaels reported issue came from MDL-33465.

              I am going to test now.

              Show
              poltawski Dan Poltawski added a comment - I think Michaels reported issue came from MDL-33465 . I am going to test now.
              Hide
              poltawski Dan Poltawski added a comment -

              Skipping 'database' enrolment plugin. Will be implemented before 2.0 release
              line 1509 of /backup/moodle2/restore_stepslib.php: call to debugging()
              line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_enrolments_structure_step->process_enrol()
              line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
              line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
              line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
              line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
              line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
              line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
              line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
              line ? of unknownfile: call to progressive_parser->end_tag()
              line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
              line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
              line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
              line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
              line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
              line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
              line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
              line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
              line 46 of /backup/restore.php: call to restore_ui->execute()
              Mapped user id not found for grade item id '20'
              line 225 of /backup/moodle2/restore_stepslib.php: call to debugging()
              line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->process_grade_grade()
              line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
              line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
              line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
              line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
              line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
              line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
              line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
              line ? of unknownfile: call to progressive_parser->end_tag()
              line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
              line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
              line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
              line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
              line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
              line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
              line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
              line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
              line 46 of /backup/restore.php: call to restore_ui->execute()
              Skip to main content

              Error writing to database

              More information about this error

              Debug info: ERROR: duplicate key value violates unique constraint "mdl_gradgrad_useite_uix"
              DETAIL: Key (userid, itemid)=(0, 20) already exists.
              INSERT INTO mdl_grade_grades (userid,rawgrade,rawgrademax,rawgrademin,rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported,overridden,excluded,feedback,feedbackformat,information,informationformat,timecreated,timemodified,itemid) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20) RETURNING id
              [array (
              'userid' => 0,
              'rawgrade' => NULL,
              'rawgrademax' => '100.00000',
              'rawgrademin' => '0.00000',
              'rawscaleid' => NULL,
              'usermodified' => NULL,
              'finalgrade' => NULL,
              'hidden' => '0',
              'locked' => '0',
              'locktime' => '0',
              'exported' => '0',
              'overridden' => '0',
              'excluded' => '0',
              'feedback' => NULL,
              'feedbackformat' => '0',
              'information' => NULL,
              'informationformat' => '0',
              'timecreated' => NULL,
              'timemodified' => NULL,
              'itemid' => '20',
              )]
              Error code: dmlwriteexception
              Stack trace:
              line 416 of /lib/dml/moodle_database.php: dml_write_exception thrown
              line 243 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
              line 807 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
              line 859 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
              line 223 of /backup/moodle2/restore_stepslib.php: call to pgsql_native_moodle_database->insert_record()
              line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->process_grade_grade()
              line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
              line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
              line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
              line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
              line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
              line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
              line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
              line ? of unknownfile: call to progressive_parser->end_tag()
              line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
              line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
              line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
              line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
              line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
              line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
              line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
              line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
              line 46 of /backup/restore.php: call to restore_ui->execute()

              Show
              poltawski Dan Poltawski added a comment - Skipping 'database' enrolment plugin. Will be implemented before 2.0 release line 1509 of /backup/moodle2/restore_stepslib.php: call to debugging() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_enrolments_structure_step->process_enrol() line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process() line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk() line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk() line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk() line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk() line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish() line ? of unknownfile: call to progressive_parser->end_tag() line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse() line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse() line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process() line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute() line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute() line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute() line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute() Mapped user id not found for grade item id '20' line 225 of /backup/moodle2/restore_stepslib.php: call to debugging() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->process_grade_grade() line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process() line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk() line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk() line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk() line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk() line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish() line ? of unknownfile: call to progressive_parser->end_tag() line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse() line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse() line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process() line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute() line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute() line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute() line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute() Skip to main content Error writing to database More information about this error Debug info: ERROR: duplicate key value violates unique constraint "mdl_gradgrad_useite_uix" DETAIL: Key (userid, itemid)=(0, 20) already exists. INSERT INTO mdl_grade_grades (userid,rawgrade,rawgrademax,rawgrademin,rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported,overridden,excluded,feedback,feedbackformat,information,informationformat,timecreated,timemodified,itemid) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20) RETURNING id [array ( 'userid' => 0, 'rawgrade' => NULL, 'rawgrademax' => '100.00000', 'rawgrademin' => '0.00000', 'rawscaleid' => NULL, 'usermodified' => NULL, 'finalgrade' => NULL, 'hidden' => '0', 'locked' => '0', 'locktime' => '0', 'exported' => '0', 'overridden' => '0', 'excluded' => '0', 'feedback' => NULL, 'feedbackformat' => '0', 'information' => NULL, 'informationformat' => '0', 'timecreated' => NULL, 'timemodified' => NULL, 'itemid' => '20', )] Error code: dmlwriteexception Stack trace: line 416 of /lib/dml/moodle_database.php: dml_write_exception thrown line 243 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() line 807 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() line 859 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw() line 223 of /backup/moodle2/restore_stepslib.php: call to pgsql_native_moodle_database->insert_record() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->process_grade_grade() line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process() line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk() line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk() line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk() line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk() line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish() line ? of unknownfile: call to progressive_parser->end_tag() line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse() line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse() line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process() line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute() line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute() line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute() line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute()
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Well, have not looked deep here and it sounds to me that there are some pending issues about "external" enrollments not being handled at all by backup & restore.

              But, in any case, I think we always should check, before restoring any user grade that:

              1) The user exists. aka, the mapping id returns some matching.
              2) The user is enrolled. no grades are allowed for not enrolled users.

              At least that way, this would work consistently, leaving those "database" enrolled users out from the equation (incorrectly) but at least consistently.

              And once the existing issues about external enrollments are fixed... this will continue working without modification, because 1) and 2) will continue being valid.

              So IMO we need, for now, to apply check for 1) and 2) and done. Ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Well, have not looked deep here and it sounds to me that there are some pending issues about "external" enrollments not being handled at all by backup & restore. But, in any case, I think we always should check, before restoring any user grade that: 1) The user exists. aka, the mapping id returns some matching. 2) The user is enrolled. no grades are allowed for not enrolled users. At least that way, this would work consistently, leaving those "database" enrolled users out from the equation (incorrectly) but at least consistently. And once the existing issues about external enrollments are fixed... this will continue working without modification, because 1) and 2) will continue being valid. So IMO we need, for now, to apply check for 1) and 2) and done. Ciao
              Hide
              skodak Petr Skoda added a comment -

              In case of enrol_database individual enrolments have to be skipped because they are controlled by the site-wide settings of the plugin, I am planning to add option to restore them as manual enrolments (optionally suspended) and the restore process should also execute full enrol sync of all plugins - the idea is that database and ldap should be able to sync using the course->idnumber/id/shortname in the middle of the restore process no matter if they were used in original course.

              Show
              skodak Petr Skoda added a comment - In case of enrol_database individual enrolments have to be skipped because they are controlled by the site-wide settings of the plugin, I am planning to add option to restore them as manual enrolments (optionally suspended) and the restore process should also execute full enrol sync of all plugins - the idea is that database and ldap should be able to sync using the course->idnumber/id/shortname in the middle of the restore process no matter if they were used in original course.
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Yup, there is pending work to do related to those enrol plugins for sure.

              In any case it does not invalidate that both 1) and 2) should be verified always when restoring grade_grades (and group_members, and everything that usually is deleted on user_unenrol()).

              More yet... it seems that this patch is perfectly valid (it's looking for user->id mapping properly before inserting) so it should no be leading to that error (dupe 0-xx).

              So for me, it seems there is some regression somewhere causing this to fail... looking...

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Yup, there is pending work to do related to those enrol plugins for sure. In any case it does not invalidate that both 1) and 2) should be verified always when restoring grade_grades (and group_members, and everything that usually is deleted on user_unenrol()). More yet... it seems that this patch is perfectly valid (it's looking for user->id mapping properly before inserting) so it should no be leading to that error (dupe 0-xx). So for me, it seems there is some regression somewhere causing this to fail... looking...
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Uhm, the get_mappingid() is returning 0, it should return null... sounds like something has stopped working there... looking...

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Uhm, the get_mappingid() is returning 0, it should return null... sounds like something has stopped working there... looking...
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Reuhm...

              something is looking borked with the recently-introduced backup_ids caches... I'm not able to get correct results there... debugging a bit more...

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Reuhm... something is looking borked with the recently-introduced backup_ids caches... I'm not able to get correct results there... debugging a bit more...
              Hide
              bigdog1742 mark jones added a comment -

              while restoring a course into moodle_23_stable i get the error.Coding error detected, it must be fixed by a programmer, Invalid component used in plugin_support():enrol_

              any idea how or when the fix is ready?

              Show
              bigdog1742 mark jones added a comment - while restoring a course into moodle_23_stable i get the error.Coding error detected, it must be fixed by a programmer, Invalid component used in plugin_support():enrol_ any idea how or when the fix is ready?
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Mark, can you create a separate issue for that, including the complete error (stack trace) and instructions to reproduce it? TIA!

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Mark, can you create a separate issue for that, including the complete error (stack trace) and instructions to reproduce it? TIA!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment - - edited

              Well, apart from any consideration about the returned values and the check (I think we should be using !empty() to control both zeros and nulls), this backup is really strange:

              A- only users 3 & 4 appear as enrolled (course/enrolments.xml).
              B- only users 2, 3 & 4 are included in backup (users.xml).
              C- there are grade_grade for users 1, 2, 3, 4 & 5 (gradebook.xml).

              And that last point should be impossible. No way there are grades for non-enrolled users.

              Also note that we are only applying the check to principal grade_grades, and not to activity grade_grades. Surely the same check should be there to detect and skip non-existing users too.

              More tomorrow, ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - - edited Well, apart from any consideration about the returned values and the check (I think we should be using !empty() to control both zeros and nulls), this backup is really strange: A- only users 3 & 4 appear as enrolled (course/enrolments.xml). B- only users 2, 3 & 4 are included in backup (users.xml). C- there are grade_grade for users 1, 2, 3, 4 & 5 (gradebook.xml). And that last point should be impossible. No way there are grades for non-enrolled users. Also note that we are only applying the check to principal grade_grades, and not to activity grade_grades. Surely the same check should be there to detect and skip non-existing users too. More tomorrow, ciao
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Oki, so, these is the plan:

              1) About A-C (moodle inconsistency): MDL-33505 (Andrew)
              2) About B-C (backup inconsistency, caused by moodle inconsistecy but who cares): MDL-33626 (Eloy).
              3) Fix this by changing current isset() by !empty() that will cover both ZEROs and NULLs (both can happen due to A-C and A-B).
              4) Apply the same check also to restore_activity_grades_structure_step, just in case.

              Ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Oki, so, these is the plan: 1) About A-C (moodle inconsistency): MDL-33505 (Andrew) 2) About B-C (backup inconsistency, caused by moodle inconsistecy but who cares): MDL-33626 (Eloy). 3) Fix this by changing current isset() by !empty() that will cover both ZEROs and NULLs (both can happen due to A-C and A-B). 4) Apply the same check also to restore_activity_grades_structure_step, just in case. Ciao
              Hide
              ppichet Pierre Pichet added a comment -

              I pinpoint another problem when working on restoring a course into a new course.(working on MDL-33586)
              I just put a simple quiz with 2 questions in a new course.
              I did some attempts.
              backup the course and restore it as a new course in the same moodle installation.
              Things seem Ok with the exception that the new questions created in the process where put in a new category which is OK.
              However the new category was in the original course, NOT in the new course.
              I used last $version = 2012060100

              Do you have the same results ?

              Show
              ppichet Pierre Pichet added a comment - I pinpoint another problem when working on restoring a course into a new course.(working on MDL-33586 ) I just put a simple quiz with 2 questions in a new course. I did some attempts. backup the course and restore it as a new course in the same moodle installation. Things seem Ok with the exception that the new questions created in the process where put in a new category which is OK. However the new category was in the original course, NOT in the new course. I used last $version = 2012060100 Do you have the same results ?
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Pierre, could you please fill that as another issue and point to it from here and/or MDL-33586. Thanks!

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Pierre, could you please fill that as another issue and point to it from here and/or MDL-33586 . Thanks!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Update:

              Information about the xml structures:

              A- only users 3 & 4 appear as enrolled (course/enrolments.xml).
              B- only users 2, 3 & 4 are included in backup (users.xml).
              C- there are grade_grade for users 1, 2, 3, 4 & 5 (gradebook.xml).

              Information about the restore process:

              D- There is something wrong with the newly introduced backup ids cache. Depending of the the process, the temporal DB tables can be dropped and recreated (once the prechecks phase ends and the restore execution begins). And we are not invalidating the cache, leading to information only present in the cache and not in DB. Can imagine all sort of problems with that).

              TODO:

              1) About A-C (moodle inconsistency): MDL-33505 (Andrew)
              2) About B-C (backup inconsistency, caused by moodle inconsistecy but who cares): MDL-33626 (Eloy).
              3) Fix this by changing current isset() by !empty() that will cover both ZEROs and NULLs (both can happen due to A-C and A-B).
              4) Apply the same check also to restore_activity_grades_structure_step, just in case.
              5) About D: Ensure that each time the temp tables are dropped, the in-memory cache is invalidated: MDL-33630

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Update: Information about the xml structures: A- only users 3 & 4 appear as enrolled (course/enrolments.xml). B- only users 2, 3 & 4 are included in backup (users.xml). C- there are grade_grade for users 1, 2, 3, 4 & 5 (gradebook.xml). Information about the restore process: D- There is something wrong with the newly introduced backup ids cache. Depending of the the process, the temporal DB tables can be dropped and recreated (once the prechecks phase ends and the restore execution begins). And we are not invalidating the cache, leading to information only present in the cache and not in DB. Can imagine all sort of problems with that). TODO: 1) About A-C (moodle inconsistency): MDL-33505 (Andrew) 2) About B-C (backup inconsistency, caused by moodle inconsistecy but who cares): MDL-33626 (Eloy). 3) Fix this by changing current isset() by !empty() that will cover both ZEROs and NULLs (both can happen due to A-C and A-B). 4) Apply the same check also to restore_activity_grades_structure_step, just in case. 5) About D: Ensure that each time the temp tables are dropped, the in-memory cache is invalidated: MDL-33630
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment - - edited

              Proposing new commit to be added:

              master: https://github.com/stronk7/moodle/commit/9cfefc4c3d42235c4a77897834c66367023a65a8

              and its clean cherry-backports:

              22: https://github.com/stronk7/moodle/commit/c0469960871037adcac07db5cdd62ae57c36d88c
              21: https://github.com/stronk7/moodle/commit/fdcf5ec267bbdb09c264228b80e067dd338323d7

              it changes the !is_null() by !empty() so any 0, false, null will lead to record being skipped.

              Also has been applied both to the global grade_grades and to the activity ones.

              Information for integrators: This must be integrated and tested after MDL-33630.

              Ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - - edited Proposing new commit to be added: master: https://github.com/stronk7/moodle/commit/9cfefc4c3d42235c4a77897834c66367023a65a8 and its clean cherry-backports: 22: https://github.com/stronk7/moodle/commit/c0469960871037adcac07db5cdd62ae57c36d88c 21: https://github.com/stronk7/moodle/commit/fdcf5ec267bbdb09c264228b80e067dd338323d7 it changes the !is_null() by !empty() so any 0, false, null will lead to record being skipped. Also has been applied both to the global grade_grades and to the activity ones. Information for integrators: This must be integrated and tested after MDL-33630 . Ciao
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks Eloy, for working on this
              Changes look good and works fine.

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks Eloy, for working on this Changes look good and works fine.
              Hide
              nebgor Aparup Banerjee added a comment -

              Thanks, those patches have been integrated respectively into master, 22 and 21 branches.

              all branches have tested fine with the 'modified' mbz.

              passing this.

              Show
              nebgor Aparup Banerjee added a comment - Thanks, those patches have been integrated respectively into master, 22 and 21 branches. all branches have tested fine with the 'modified' mbz. passing this.
              Hide
              nebgor Aparup Banerjee added a comment -

              tested during integration on 21,22 and master = passed. go for mdlqa test.

              Show
              nebgor Aparup Banerjee added a comment - tested during integration on 21,22 and master = passed. go for mdlqa test.
              Hide
              bigdog1742 mark jones added a comment -

              would there be a way to get the patch now as i have a major issue not being able to restore. mark

              Show
              bigdog1742 mark jones added a comment - would there be a way to get the patch now as i have a major issue not being able to restore. mark
              Hide
              nebgor Aparup Banerjee added a comment -

              Hi Mark,
              you can pull the 2 commits right now from our integration repository.
              see http://git.moodle.org/gw?p=integration.git&a=search&h=HEAD&st=commit&s=MDL-33455

              Show
              nebgor Aparup Banerjee added a comment - Hi Mark, you can pull the 2 commits right now from our integration repository. see http://git.moodle.org/gw?p=integration.git&a=search&h=HEAD&st=commit&s=MDL-33455
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3.

              Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish.

              Many thanks for your collaboration!

              Ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3. Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish. Many thanks for your collaboration! Ciao
              Hide
              tinania Tina Schaefer added a comment - - edited

              It says that this issue is fixed. However, I have just tried to restore a Moodle 2.1.3 course backup into 2.2.4 and received the following error: Coding error detected, it must be fixed by a programmer: Invalid component used in plugin_supports():enrol_

              ◦line 8004 of \lib\moodlelib.php: coding_exception thrown
              ◦line 1361 of \backup\moodle2\restore_stepslib.php: call to plugin_supports()
              ◦line 131 of \backup\util\plan\restore_structure_step.class.php: call to restore_enrolments_structure_step->process_enrol()
              ◦line 103 of \backup\util\helper\restore_structure_parser_processor.class.php: call to restore_structure_step->process()
              ◦line 125 of \backup\util\xml\parser\processors\grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
              ◦line 91 of \backup\util\helper\restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
              ◦line 148 of \backup\util\xml\parser\processors\simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
              ◦line 92 of \backup\util\xml\parser\processors\progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
              ◦line 169 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
              ◦line 253 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser->publish()
              ◦line ? of unknownfile: call to progressive_parser->end_tag()
              ◦line 158 of \backup\util\xml\parser\progressive_parser.class.php: call to xml_parse()
              ◦line 137 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser->parse()
              ◦line 105 of \backup\util\plan\restore_structure_step.class.php: call to progressive_parser->process()
              ◦line 153 of \backup\util\plan\base_task.class.php: call to restore_structure_step->execute()
              ◦line 148 of \backup\util\plan\base_plan.class.php: call to base_task->execute()
              ◦line 157 of \backup\util\plan\restore_plan.class.php: call to base_plan->execute()
              ◦line 315 of \backup\controller\restore_controller.class.php: call to restore_plan->execute()
              ◦line 147 of \backup\util\ui\restore_ui.class.php: call to restore_controller->execute_plan()
              ◦line 46 of \backup\restore.php: call to restore_ui->execute()

              I unticked all user data since I don't want the user ids to match up because they are different. I just want to restore the content. Is that possible?

              Ok, I just unenrolled all users that have mismatching user ids from that course, backed it up and tried to restore in 2.2.4. I still get this error

              Now I upgraded 2.1.3 page to 2.2.4, backed up, and restored on different 2.2.4 page and ... I still get this error message.

              Show
              tinania Tina Schaefer added a comment - - edited It says that this issue is fixed. However, I have just tried to restore a Moodle 2.1.3 course backup into 2.2.4 and received the following error: Coding error detected, it must be fixed by a programmer: Invalid component used in plugin_supports():enrol_ ◦line 8004 of \lib\moodlelib.php: coding_exception thrown ◦line 1361 of \backup\moodle2\restore_stepslib.php: call to plugin_supports() ◦line 131 of \backup\util\plan\restore_structure_step.class.php: call to restore_enrolments_structure_step->process_enrol() ◦line 103 of \backup\util\helper\restore_structure_parser_processor.class.php: call to restore_structure_step->process() ◦line 125 of \backup\util\xml\parser\processors\grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk() ◦line 91 of \backup\util\helper\restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk() ◦line 148 of \backup\util\xml\parser\processors\simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() ◦line 92 of \backup\util\xml\parser\processors\progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk() ◦line 169 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser_processor->receive_chunk() ◦line 253 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser->publish() ◦line ? of unknownfile: call to progressive_parser->end_tag() ◦line 158 of \backup\util\xml\parser\progressive_parser.class.php: call to xml_parse() ◦line 137 of \backup\util\xml\parser\progressive_parser.class.php: call to progressive_parser->parse() ◦line 105 of \backup\util\plan\restore_structure_step.class.php: call to progressive_parser->process() ◦line 153 of \backup\util\plan\base_task.class.php: call to restore_structure_step->execute() ◦line 148 of \backup\util\plan\base_plan.class.php: call to base_task->execute() ◦line 157 of \backup\util\plan\restore_plan.class.php: call to base_plan->execute() ◦line 315 of \backup\controller\restore_controller.class.php: call to restore_plan->execute() ◦line 147 of \backup\util\ui\restore_ui.class.php: call to restore_controller->execute_plan() ◦line 46 of \backup\restore.php: call to restore_ui->execute() I unticked all user data since I don't want the user ids to match up because they are different. I just want to restore the content. Is that possible? Ok, I just unenrolled all users that have mismatching user ids from that course, backed it up and tried to restore in 2.2.4. I still get this error Now I upgraded 2.1.3 page to 2.2.4, backed up, and restored on different 2.2.4 page and ... I still get this error message.
              Hide
              nebgor Aparup Banerjee added a comment -

              Hi Tina,
              This issue seems to be a different issue from your issue. MDL-33520 looks like the same issue you are facing. I've added you as a watcher on that issue now.

              Show
              nebgor Aparup Banerjee added a comment - Hi Tina, This issue seems to be a different issue from your issue. MDL-33520 looks like the same issue you are facing. I've added you as a watcher on that issue now.

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    9/Jul/12