Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-35146 mod_wiki: fixed issue where pages for deleted groups caused…

… an error on restore
  • Loading branch information...
commit 19b2d3fa9c9577fc960631c89cc3b3ae695bba9b 1 parent 68291f2
Anton Fletcher salmonmoose authored markn86 committed

Showing 1 changed file with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. +12 4 mod/wiki/backup/moodle2/restore_wiki_stepslib.php
16 mod/wiki/backup/moodle2/restore_wiki_stepslib.php
@@ -74,10 +74,14 @@ protected function process_wiki_subwiki($data) {
74 74 $data = (object)$data;
75 75 $oldid = $data->id;
76 76 $data->wikiid = $this->get_new_parentid('wiki');
77   - $data->groupid = $this->get_mappingid('group', $data->groupid);
78   - $data->userid = $this->get_mappingid('user', $data->userid);
  77 + if($data->groupid !== '0') $data->groupid = $this->get_mappingid('group', $data->groupid);
  78 + if($date->userid !== '0') $data->userid = $this->get_mappingid('user', $data->userid);
79 79
80   - $newitemid = $DB->insert_record('wiki_subwikis', $data);
  80 + if($data->groupid !== false && $data->userid !== false) {
  81 + $newitemid = $DB->insert_record('wiki_subwikis', $data);
  82 + } else {
  83 + $newitemid = false;
  84 + }
81 85 $this->set_mapping('wiki_subwiki', $oldid, $newitemid);
82 86 }
83 87 protected function process_wiki_page($data) {
@@ -91,7 +95,11 @@ protected function process_wiki_page($data) {
91 95 $data->timecreated = $this->apply_date_offset($data->timecreated);
92 96 $data->timerendered = $this->apply_date_offset($data->timerendered);
93 97
94   - $newitemid = $DB->insert_record('wiki_pages', $data);
  98 + if($data->subwikiid !== false) {
  99 + $newitemid = $DB->insert_record('wiki_pages', $data);
  100 + } else {
  101 + $newitemid = false;
  102 + }
95 103 $this->set_mapping('wiki_page', $oldid, $newitemid, true); // There are files related to this
96 104 }
97 105 protected function process_wiki_version($data) {

0 comments on commit 19b2d3f

Please sign in to comment.
Something went wrong with that request. Please try again.