Moodle
  1. Moodle
  2. MDL-35146

Restore of wiki fails with unique constraint violation

    Details

    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide
      1. Create a course.
      2. Enrol a bunch of users into this course.
      3. Under 'Course administration' click on 'Users' then 'Groups'.
      4. Click on 'Auto-create groups'.
      5. Create at least 2 groups.
      6. Go to the course page and create a wiki with 'Group mode' set to 'Separate groups'.
      7. Click on the wiki and create the first page of the wiki with 'Group' set to 'All participants' and click 'Create page'.
      8. Set the HTML format to whatever you want and click 'Save'.
      9. Under 'Separate groups' select the first group you created.
      10. Create this page again but with the 'Group' set to the group you chose and click 'Create page'.
      11. Set the HTML format to the group name to remember it and click 'Save'.
      12. Under 'Wiki administration' click on 'Backup'.
      13. Go through the backup process with default settings.
      14. Once completed click on 'Restore' next to the name of the backup you just created.
      15. Visit the newly created wiki and check that it is the same as the wiki you created the backup of.
      16. Under 'Course administration' click on 'Users' then 'Groups'.
      17. Delete the group you created the wiki page for.
      18. Visit the first wiki you created.
      19. Under 'Wiki administration' click on 'Backup'.
      20. Go through the backup process with default settings.
      21. Once completed click on 'Restore' next to the name of the backup you just created.
      22. Follow the restore process and select the course you created in this test.
      23. Check that it restores successfully and that when browsing the wiki it is the same as the wiki you created the backup of.
      Show
      Create a course. Enrol a bunch of users into this course. Under 'Course administration' click on 'Users' then 'Groups'. Click on 'Auto-create groups'. Create at least 2 groups. Go to the course page and create a wiki with 'Group mode' set to 'Separate groups'. Click on the wiki and create the first page of the wiki with 'Group' set to 'All participants' and click 'Create page'. Set the HTML format to whatever you want and click 'Save'. Under 'Separate groups' select the first group you created. Create this page again but with the 'Group' set to the group you chose and click 'Create page'. Set the HTML format to the group name to remember it and click 'Save'. Under 'Wiki administration' click on 'Backup'. Go through the backup process with default settings. Once completed click on 'Restore' next to the name of the backup you just created. Visit the newly created wiki and check that it is the same as the wiki you created the backup of. Under 'Course administration' click on 'Users' then 'Groups'. Delete the group you created the wiki page for. Visit the first wiki you created. Under 'Wiki administration' click on 'Backup'. Go through the backup process with default settings. Once completed click on 'Restore' next to the name of the backup you just created. Follow the restore process and select the course you created in this test. Check that it restores successfully and that when browsing the wiki it is the same as the wiki you created the backup of.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull 2.4 Branch:
      MDL-35146_m24
    • Pull 2.5 Branch:
      MDL-35146_m25
    • Pull Master Branch:
      MDL-35146_master
    • Story Points:
      13
    • Rank:
      43778
    • Sprint:
      BACKEND Sprint 6

      Description

      In a Moodle 2.3.1 that was upgraded from 1.9.x => 2.2.x => 2.3.1, backing up then restoring a course with a particular wiki in it fails with a database error.

      Although the database has some data related to this wiki, it appears when viewing the wiki in the source course that it has no pages.

      The wiki was created before the upgrade from 1.9 to 2.3.1.

      Default exception handler: Error writing to database Debug: ERROR:  duplicate key value violates unique constraint "mdl_wikisubw_wikgrouse_uix"
      INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES($1,$2,$3) RETURNING id
      [array (
        'groupid' => 0,
        'userid' => 0,
        'wikiid' => 2749,
      )]
      Error code: dmlwriteexception
      * line 410 of /lib/dml/moodle_database.php: dml_write_exception thrown
      * line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 812 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 864 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
      * line 80 of /mod/wiki/backup/moodle2/restore_wiki_stepslib.php: call to pgsql_native_moodle_database->insert_record()
      * line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_wiki_activity_structure_step->process_wiki_subwiki()
      * 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 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
      * line ? of unknownfile: call to progressive_parser->start_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 192 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
      * line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_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()
      ...
      

      Here are the related records from the db:

      moodle=# select * from mdl_course_modules where id=179212;
         id   | course | module | instance | section | idnumber |   added    | score | indent | visible | visibleold | groupmode | groupingid | groupmembersonly | completion | completiongradeitemnumber | completionview | completionexpected | availablefrom | availableuntil | showavailability | showdescription 
      --------+--------+--------+----------+---------+----------+------------+-------+--------+---------+------------+-----------+------------+------------------+------------+---------------------------+----------------+--------------------+---------------+----------------+------------------+-----------------
       179212 |   4371 |     16 |     2557 |   52394 |          | 1327672348 |     0 |      1 |       0 |          1 |         1 |          0 |                0 |          0 |                           |              0 |                  0 |             0 |              0 |                0 |               0
      
      moodle=# select * from mdl_wiki where id=2557;
        id  | course |                               name                               | timemodified |                                  intro                                  | introformat |             firstpagetitle              |   wikimode    | defaultformat | forceformat | editbegin | editend | timecreated 
      ------+--------+------------------------------------------------------------------+--------------+-------------------------------------------------------------------------+-------------+-----------------------------------------+---------------+---------------+-------------+-----------+---------+-------------
       2557 |   4371 | anonymized "Anonymized" |   1331379009 |  Anonymized                          |           0 | anonymized "anonymized" | collaborative | html          |           1 |         0 |       0 |           0
      
      moodle=# select * from mdl_wiki_subwikis where wikiid=2557;
        id  | wikiid | groupid | userid 
      ------+--------+---------+--------
        237 |   2557 |    5646 |      0
        590 |   2557 |    5649 |      0
        650 |   2557 |    5645 |      0
        992 |   2557 |    5648 |      0
       1557 |   2557 |    5644 |      0
       1999 |   2557 |    5647 |      0
       2251 |   2557 |       0 |      0
      
      moodle=# select id, subwikiid, 'anonymized' as title, 'anonymized' as cachedcontent, timecreated, timemodified, timerendered, userid, pageviews, readonly  from mdl_wiki_pages where subwikiid in (select id from mdl_wiki_subwikis where wikiid=2557);
        id  | subwikiid |   title    | cachedcontent | timecreated | timemodified | timerendered | userid | pageviews | readonly 
      ------+-----------+------------+---------------+-------------+--------------+--------------+--------+-----------+----------
       6719 |      1557 | anonymized | anonymized    |  1327672570 |   1332150929 |   1345290323 |  13020 |       230 |        0
       6724 |      1999 | anonymized | anonymized    |  1327672984 |   1332460271 |   1345290323 |  13044 |       111 |        0
       6723 |       590 | anonymized | anonymized    |  1327672870 |   1333543094 |   1345290323 |   6542 |       119 |        0
       7290 |      2251 | anonymized | anonymized    |  1346323212 |   1346323212 |   1346327547 |  20760 |         8 |        0
       6721 |       237 | anonymized | anonymized    |  1327672701 |   1331551184 |   1345290323 |   9094 |       117 |        0
       6720 |       650 | anonymized | anonymized    |  1327672976 |   1334228293 |   1345290323 |  10764 |        94 |        0
       6722 |       992 | anonymized | anonymized    |  1327672861 |   1332347078 |   1345290323 |  10845 |       140 |        0
      

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for reporting that.

          Feel free to work on the issue with us.

          Show
          Michael de Raadt added a comment - Thanks for reporting that. Feel free to work on the issue with us.
          Hide
          Jean-Francois Belisle added a comment - - edited

          Same problem here with 2.4.3+

          Backup made in 2.2.9 and restored in 2.4.3+

          Debug info: Duplicate entry '78-0-0' for key 'mdl_wikisubw_wikgrouse_uix'
          INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES(?,?,?)
          [array (
          0 => 0,
          1 => 0,
          2 => 78,
          )]
          Error code: dmlwriteexception
          Stack trace:
          line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown
          line 1107 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
          line 1149 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
          line 80 of /mod/wiki/backup/moodle2/restore_wiki_stepslib.php: call to mysqli_native_moodle_database->insert_record()
          line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_wiki_activity_structure_step->process_wiki_subwiki()
          line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
          line 139 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 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
          line ? of unknownfile: call to progressive_parser->start_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 192 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
          line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_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()
          
          

          And if I try to restore the same course another time, the key (2) would go from 78 to 79 and so on, always incrementing by one.

          Is the problem solved already or can I help to resolved it ?

          Show
          Jean-Francois Belisle added a comment - - edited Same problem here with 2.4.3+ Backup made in 2.2.9 and restored in 2.4.3+ Debug info: Duplicate entry '78-0-0' for key 'mdl_wikisubw_wikgrouse_uix' INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES(?,?,?) [array ( 0 => 0, 1 => 0, 2 => 78, )] Error code: dmlwriteexception Stack trace: line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown line 1107 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 1149 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() line 80 of /mod/wiki/backup/moodle2/restore_wiki_stepslib.php: call to mysqli_native_moodle_database->insert_record() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_wiki_activity_structure_step->process_wiki_subwiki() line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process() line 139 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 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish() line ? of unknownfile: call to progressive_parser->start_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 192 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute() line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_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() And if I try to restore the same course another time, the key (2) would go from 78 to 79 and so on, always incrementing by one. Is the problem solved already or can I help to resolved it ?
          Hide
          Rajesh Taneja added a comment -

          Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

          For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

          If you have any information about this issue or a possible fix please post it here

          Show
          Rajesh Taneja added a comment - Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment If you have any information about this issue or a possible fix please post it here
          Hide
          Yvonne Hamilton added a comment -

          We are LAMP environment that upgraded from 1.9 to 2.1.4 to 2.1.8 to 2.4.4 and wikis were bad in 2.1.4 but at least we could work around all the loss of functionality (initial HTML first page, groups working correctly) but they just seem to get worse every upgrade.
          I cannot restore courses from a refesh backup in 2.4.4 to a new course without removing all the wikis from the restore process.
          The wiki's have been such a disappointment in Moodle2
          Here is our debug info from a failed course restore:

          Debug info: Duplicate entry '1922-0-0' for key 'mdl_wikisubw_wikgrouse_uix'
          INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES(?,?,?)
          [array (
          0 => 0,
          1 => 0,
          2 => 1922,
          )]
          Error code: dmlwriteexception
          Stack trace:
          • line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown
          • line 1107 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
          • line 1149 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
          • line 80 of /mod/wiki/backup/moodle2/restore_wiki_stepslib.php: call to mysqli_native_moodle_database->insert_record()
          • line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_wiki_activity_structure_step->process_wiki_subwiki()
          • line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
          • line 139 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 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
          • line ? of unknownfile: call to progressive_parser->start_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 192 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
          • line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_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
          Yvonne Hamilton added a comment - We are LAMP environment that upgraded from 1.9 to 2.1.4 to 2.1.8 to 2.4.4 and wikis were bad in 2.1.4 but at least we could work around all the loss of functionality (initial HTML first page, groups working correctly) but they just seem to get worse every upgrade. I cannot restore courses from a refesh backup in 2.4.4 to a new course without removing all the wikis from the restore process. The wiki's have been such a disappointment in Moodle2 Here is our debug info from a failed course restore: Debug info: Duplicate entry '1922-0-0' for key 'mdl_wikisubw_wikgrouse_uix' INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES(?,?,?) [array ( 0 => 0, 1 => 0, 2 => 1922, )] Error code: dmlwriteexception Stack trace: • line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown • line 1107 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() • line 1149 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() • line 80 of /mod/wiki/backup/moodle2/restore_wiki_stepslib.php: call to mysqli_native_moodle_database->insert_record() • line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_wiki_activity_structure_step->process_wiki_subwiki() • line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process() • line 139 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 212 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish() • line ? of unknownfile: call to progressive_parser->start_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 192 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute() • line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_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
          Tim Lock added a comment - - edited

          I also have this problem by slightly different where I'm moving courses from 2.2.2 after upgraded from 1.9.x to another 2.2.2 with userdata.

          SQL: INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES($1,$2,$3) RETURNING id [Array
          (
          [groupid] => 0
          [userid] => 0
          [wikiid] => 507
          )
          ]
          Caught exception restoring COURSE_2010: Error writing to database
          Stacktrace:
          #0 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(286): moodle_database->query_end(false)
          #1 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(912): pgsql_native_moodle_database->query_end(false)
          #2 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(964): pgsql_native_moodle_database->insert_record_raw('wiki_subwikis', Array, true, false)

          Show
          Tim Lock added a comment - - edited I also have this problem by slightly different where I'm moving courses from 2.2.2 after upgraded from 1.9.x to another 2.2.2 with userdata. SQL: INSERT INTO mdl_wiki_subwikis (groupid,userid,wikiid) VALUES($1,$2,$3) RETURNING id [Array ( [groupid] => 0 [userid] => 0 [wikiid] => 507 ) ] Caught exception restoring COURSE_2010: Error writing to database Stacktrace: #0 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(286): moodle_database->query_end(false) #1 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(912): pgsql_native_moodle_database->query_end(false) #2 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(964): pgsql_native_moodle_database->insert_record_raw('wiki_subwikis', Array, true, false)
          Hide
          Tim Lock added a comment -

          My workaround was to run this against the database to remove orphaned sub wikis when groups had been removed.

          delete from mdl_wiki_subwikis where groupid not in (select id from mdl_groups) and groupid != 0;

          Show
          Tim Lock added a comment - My workaround was to run this against the database to remove orphaned sub wikis when groups had been removed. delete from mdl_wiki_subwikis where groupid not in (select id from mdl_groups) and groupid != 0;
          Hide
          Anton Fletcher added a comment -

          This will allow imports without running Tim's sanitation before export.

          https://github.com/salmonmoose/moodle/commit/63847895149a4223b8d138b43c96d32902674ecd

          Show
          Anton Fletcher added a comment - This will allow imports without running Tim's sanitation before export. https://github.com/salmonmoose/moodle/commit/63847895149a4223b8d138b43c96d32902674ecd
          Hide
          Francis Devine added a comment - - edited

          Hey all

          We had the same issue with a 2.3 moodle install, Anton's patch worked for us

          However Anton, looks like you have a slight spelling mistake on line 78 there

          $date instead of $data

          Apart from that it's a +1 from me.

          edit: line 78 not 73

          Show
          Francis Devine added a comment - - edited Hey all We had the same issue with a 2.3 moodle install, Anton's patch worked for us However Anton, looks like you have a slight spelling mistake on line 78 there $date instead of $data Apart from that it's a +1 from me. edit: line 78 not 73
          Hide
          Jean-Francois Belisle added a comment -

          Same here with 2.5.2, Anton's patch did it.

          Thank you

          Show
          Jean-Francois Belisle added a comment - Same here with 2.5.2, Anton's patch did it. Thank you
          Hide
          Mark Nelson added a comment -

          Hi guys, I am going to try replicate this today.

          From what I can tell these are the steps to replicate -

          1. Create a 1.9 site with a course that contains wikis.
          2. Upgrade to 2.2 then to 2.3.
          3. Backup the course and then restore it to receive the error.

          If I am missing a step, or if any of these are wrong please let me know.

          Show
          Mark Nelson added a comment - Hi guys, I am going to try replicate this today. From what I can tell these are the steps to replicate - Create a 1.9 site with a course that contains wikis. Upgrade to 2.2 then to 2.3. Backup the course and then restore it to receive the error. If I am missing a step, or if any of these are wrong please let me know.
          Hide
          Anton Fletcher added a comment -

          I believe you can trigger the error far easier;

          1. Create a course that contains a wiki and multiple groups.
          2. Create pages for groups.
          3. Delete a group that you have made pages for.
          4. Backup and Restore course.

          My patch throws away the orphaned pages - something that should probably happen when the group is initially removed.

          Show
          Anton Fletcher added a comment - I believe you can trigger the error far easier; 1. Create a course that contains a wiki and multiple groups. 2. Create pages for groups. 3. Delete a group that you have made pages for. 4. Backup and Restore course. My patch throws away the orphaned pages - something that should probably happen when the group is initially removed.
          Hide
          Mark Nelson added a comment -

          Thanks Anton, I had to play with your instructions a bit in order to replicate this issue but have now found a set of clear steps that will lead to this error.

          Show
          Mark Nelson added a comment - Thanks Anton, I had to play with your instructions a bit in order to replicate this issue but have now found a set of clear steps that will lead to this error.
          Hide
          Mark Nelson added a comment -

          An event is thrown when a group is deleted. We could add a handler to delete any wiki pages created for these groups, or simply handle it during the restore which is what your patch is doing. I am going to discuss this more tomorrow to see if there is a consensus with the other developers.

          Show
          Mark Nelson added a comment - An event is thrown when a group is deleted. We could add a handler to delete any wiki pages created for these groups, or simply handle it during the restore which is what your patch is doing. I am going to discuss this more tomorrow to see if there is a consensus with the other developers.
          Hide
          Anton Fletcher added a comment -

          I suspect the best option is both - allowing existing "broken" courses to be imported, and also cleaning up after deletions (which may lead to other problems).

          Show
          Anton Fletcher added a comment - I suspect the best option is both - allowing existing "broken" courses to be imported, and also cleaning up after deletions (which may lead to other problems).
          Hide
          Mark Nelson added a comment -

          Yep, after I wrote that last message I thought abt it and decided that for BC we need to incorporate at least your patch, so I agree.

          Show
          Mark Nelson added a comment - Yep, after I wrote that last message I thought abt it and decided that for BC we need to incorporate at least your patch, so I agree.
          Hide
          Mark Nelson added a comment -

          After discussing in DEV chat it was decided we would leave the data and possibly implement an interface later on to view the data that has been lost into the abyss. The same issue happens in forums as well, which does not delete the data.

          Show
          Mark Nelson added a comment - After discussing in DEV chat it was decided we would leave the data and possibly implement an interface later on to view the data that has been lost into the abyss. The same issue happens in forums as well, which does not delete the data.
          Hide
          Rajesh Taneja added a comment -

          Thanks for the fixing this Brian and Mark.

          Overall patch looks good.
          Few things to consider:

          1. It's good that you have adding space after typecasting, but it seems redundant as rest of the code is not doing it.
          2. Have you considered that case where groupid and userid === 0. You are type casting them to int and comparing if it's not 0, then below you are comparing boolean. Seems (int) 0 if passed will return $newitemid = false.

          Feel free to push it for integration when ready.

          Show
          Rajesh Taneja added a comment - Thanks for the fixing this Brian and Mark. Overall patch looks good. Few things to consider: It's good that you have adding space after typecasting, but it seems redundant as rest of the code is not doing it. Have you considered that case where groupid and userid === 0. You are type casting them to int and comparing if it's not 0, then below you are comparing boolean. Seems (int) 0 if passed will return $newitemid = false. Feel free to push it for integration when ready.
          Hide
          Mark Nelson added a comment -

          Hi Raj,

          Thanks.

          We want to compare it to a boolean as $this->get_mappingid('user', $data->userid); will return false if no mapping is found.

          Submitting to integration.

          Cheers!

          Show
          Mark Nelson added a comment - Hi Raj, Thanks. We want to compare it to a boolean as $this->get_mappingid('user', $data->userid); will return false if no mapping is found. Submitting to integration. Cheers!
          Hide
          Damyon Wiese added a comment -

          Thanks Anton and Mark,

          The fix makes sense, unit tests still pass (but don't cover this anyway).

          Integrated to 24, 25 and master. Off to testing...

          Show
          Damyon Wiese added a comment - Thanks Anton and Mark, The fix makes sense, unit tests still pass (but don't cover this anyway). Integrated to 24, 25 and master. Off to testing...
          Hide
          Jason Fowler added a comment -

          All good, thanks Mark!

          Show
          Jason Fowler added a comment - All good, thanks Mark!
          Hide
          Damyon Wiese added a comment -

          Here lies 52 bugs.
          All fixed or swept under a rug.
          If they come back one day,
          To our dismay,
          We all will feel quite un-smug.

          Thanks for the reporting/fixing/testing on this issue. It has been sent upstream.

          Show
          Damyon Wiese added a comment - Here lies 52 bugs. All fixed or swept under a rug. If they come back one day, To our dismay, We all will feel quite un-smug. Thanks for the reporting/fixing/testing on this issue. It has been sent upstream.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Agile