Moodle
  1. Moodle
  2. MDL-31532

Restoring 1.9 backup to 2.2 postgresq fails (null value in column "hiddensections" violates not-null constraint)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.7, 2.1.4, 2.2.1
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Backup
    • Labels:
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide

      Try to restore the "hacked" backup file (null_hidden_sections.mbz). It has been forced to have the course->hiddensections tag to null.

      1) without the patch, it will lead to DB error about NULL value not allowed.
      2) with the fix applied, it will restore without error.

      Show
      Try to restore the "hacked" backup file (null_hidden_sections.mbz). It has been forced to have the course->hiddensections tag to null. 1) without the patch, it will lead to DB error about NULL value not allowed. 2) with the fix applied, it will restore without error.
    • Workaround:
      Hide

      Attached patch. I don't know current moodle codebase well, so maybe this
      should fixed earlier stage where data is parsed. But any how, attached patch will fix the issue.

      Show
      Attached patch. I don't know current moodle codebase well, so maybe this should fixed earlier stage where data is parsed. But any how, attached patch will fix the issue.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      38084

      Description

      Trying to restore backup from moodle 1.9.x to moodle 2.2 with postgresql database.
      Got error:

      Error: null value in column "hiddensections" violates not-null constraint
      
      UPDATE mdl_course SET summaryformat = $1,legacyfiles = $2,requested = $3,restrictmodules = $4,enablecompletion = $5,completionstartonenrol = $6,completionnotify = $7,fullname = $8,shortname = $9,idnumber = $10,summary = $11,format = $12,showgrades = $13,newsitems = $14,startdate = $15,numsections = $16,maxbytes = $17,showreports = $18,groupmode = $19,groupmodeforce = $20,defaultgroupingid = $21,lang = $22,theme = $23,marker = $24,visible = $25,hiddensections = $26,timecreated = $27,timemodified = $28 WHERE id=$29\n[array (\n  'summaryformat' => '1',\n  'legacyfiles' => '2',\n  'requested' => '0',\n  'restrictmodules' => 0,\n  'enablecompletion' => 0,\n  'completionstartonenrol' => 0,\n  'completionnotify' => 0,\n  'fullname' => 'Osa 2: Tekninen piirustus (WinNova, Rauma/aikuiskoulutus)',\n  'shortname' => 'Tekn.piir. (WR_a)',\n  'idnumber' => '',\n  'summary' => ' Teknisen piirustuksen verkko-opetusaineisto kattaa kone- ja metallialan perustutkintoon sis\xc3\xa4ltyv\xc3\xa4n tietopuolisen opetuksen. Moodle-istunto on WinNovan (Rauma/aikuiskoulutus) kone- ja metallialan opiskelijoiden ja opettajien yhteinen teknisen piirustuksen opiskelualusta.',\n  'format' => 'topics',\n  'showgrades' => '1',\n  'newsitems' => '5',\n  'startdate' => 1321480800,\n  'numsections' => '14',\n  'maxbytes' => '5242880',\n  'showreports' => '0',\n  'groupmode' => '0',\n  'groupmodeforce' => '0',\n  'defaultgroupingid' => '0',\n  'lang' => '',\n  'theme' => '',\n  'marker' => '0',\n  'visible' => '1',\n  'hiddensections' => NULL,\n  'timecreated' => '1321439425',\n  'timemodified' => '1321444267',\n  0 => 941,\n)]\n* line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown\n* 
      line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()\n* 
      line 936 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()\n* 
      line 976 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->update_record_raw()\n* 
      line 1150 of /backup/moodle2/restore_stepslib.php: call to pgsql_native_moodle_database->update_record()\n* 
      line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_course_structure_step->process_course()\n* 
      line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()\n* 
      line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()\n* 
      line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()\n* 
      line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()\n* 
      line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()\n* 
      line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()\n* '
      line 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()\n* 
      line ? of unknownfile: call to progressive_parser->start_tag()\n* line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()\n* 
      line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()\n* 
      
      line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()\n* 
      line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()\n* 
      line 148 of /backup/util/plan/base_plan.class.php: call to base_task->execute()\n* line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()\n* line 310 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()\n* line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()\n* line 46 of /backup/restore.php: call to restore_ui->execute()\n, referer: http://moodle.sataedu.fi/backup/restore.php
      

        Activity

        Hide
        Michael de Raadt added a comment -

        Thanks for reporting that and providing a solution.

        Show
        Michael de Raadt added a comment - Thanks for reporting that and providing a solution.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Uhm, really strange. That field has been NOT NULL way before Moodle 1.9, so not sure how you can have one backup containing:

        <HIDDENSECTIONS>$@NULL@$</HIDDENSECTIONS>
        

        Anyway, the proposed solution does not hurt so I'm going to apply it.

        Thanks for the patch and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Uhm, really strange. That field has been NOT NULL way before Moodle 1.9, so not sure how you can have one backup containing: <HIDDENSECTIONS>$@NULL@$</HIDDENSECTIONS> Anyway, the proposed solution does not hurt so I'm going to apply it. Thanks for the patch and ciao
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Sending to integration and attaching one "hacked" backup file for testing.

        In the mean time, Petri, can you confirm the value of the HIDDENSECTIONS tag in your file?

        Thanks and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Sending to integration and attaching one "hacked" backup file for testing. In the mean time, Petri, can you confirm the value of the HIDDENSECTIONS tag in your file? Thanks and ciao
        Hide
        Sam Hemelryk added a comment -

        Hi guys,

        I've integrated this solution as it appears to be 100% safe, certainly still worth confirming the HIDDENSECTIONS by all means.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Hi guys, I've integrated this solution as it appears to be 100% safe, certainly still worth confirming the HIDDENSECTIONS by all means. Cheers Sam
        Hide
        Petri Asikainen added a comment -

        Confirmed: I find "<HIDDENSECTIONS>$@NULL@$</HIDDENSECTIONS>" in my backup file.

        Show
        Petri Asikainen added a comment - Confirmed: I find "<HIDDENSECTIONS>$@NULL@$</HIDDENSECTIONS>" in my backup file.
        Hide
        Aparup Banerjee added a comment -

        Works for me - tested on postgres.

        1) replicated (master, 22, 21)

        Debug info: ERROR: null value in column "hiddensections" violates not-null constraint

        • other branches got me the warning, nice
          "This backup file has been created with Moodle 2.3dev..."

        2) PASSED (master, 22, 21)

        no major problems found with attached test backup file

        lol@ "Got this, yay, restore worked! Please, pass MDL-31532."


        Ps:
        minor issue 2.1.x - found on stage 1 of restore - 'confirm' stage. Is another issue.

        Invalid get_string() identifier: 'rootsettingimscc11' or component 'backup'
        line 5942 of /lib/moodlelib.php: call to debugging()
        line 6532 of /lib/moodlelib.php: call to core_string_manager->get_string()
        line 101 of /backup/util/ui/renderer.php: call to get_string()
        line 202 of /backup/util/ui/restore_ui_stage.class.php: call to core_backup_renderer->backup_details()
        line 67 of /backup/restore.php: call to restore_ui_stage_confirm->display()

        Show
        Aparup Banerjee added a comment - Works for me - tested on postgres. 1) replicated (master, 22, 21) Debug info: ERROR: null value in column "hiddensections" violates not-null constraint other branches got me the warning, nice "This backup file has been created with Moodle 2.3dev..." 2) PASSED (master, 22, 21) no major problems found with attached test backup file lol@ "Got this, yay, restore worked! Please, pass MDL-31532 ." Ps: minor issue 2.1.x - found on stage 1 of restore - 'confirm' stage. Is another issue. Invalid get_string() identifier: 'rootsettingimscc11' or component 'backup' line 5942 of /lib/moodlelib.php: call to debugging() line 6532 of /lib/moodlelib.php: call to core_string_manager->get_string() line 101 of /backup/util/ui/renderer.php: call to get_string() line 202 of /backup/util/ui/restore_ui_stage.class.php: call to core_backup_renderer->backup_details() line 67 of /backup/restore.php: call to restore_ui_stage_confirm->display()
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Some changes to Moodle should be milestones in the project by themselves.

        This is not the case and your fix is not so important, but your collaboration is highly appreciated, thanks!

        Closing as fixed, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Some changes to Moodle should be milestones in the project by themselves. This is not the case and your fix is not so important, but your collaboration is highly appreciated, thanks! Closing as fixed, ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: