Skip to content
Browse files

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

… an error on restore
  • Loading branch information...
1 parent 68291f2 commit 19b2d3fa9c9577fc960631c89cc3b3ae695bba9b @salmonmoose salmonmoose committed with markn86 Oct 4, 2013
Showing with 12 additions and 4 deletions.
  1. +12 −4 mod/wiki/backup/moodle2/restore_wiki_stepslib.php
View
16 mod/wiki/backup/moodle2/restore_wiki_stepslib.php
@@ -74,10 +74,14 @@ protected function process_wiki_subwiki($data) {
$data = (object)$data;
$oldid = $data->id;
$data->wikiid = $this->get_new_parentid('wiki');
- $data->groupid = $this->get_mappingid('group', $data->groupid);
- $data->userid = $this->get_mappingid('user', $data->userid);
+ if($data->groupid !== '0') $data->groupid = $this->get_mappingid('group', $data->groupid);
+ if($date->userid !== '0') $data->userid = $this->get_mappingid('user', $data->userid);
- $newitemid = $DB->insert_record('wiki_subwikis', $data);
+ if($data->groupid !== false && $data->userid !== false) {
+ $newitemid = $DB->insert_record('wiki_subwikis', $data);
+ } else {
+ $newitemid = false;
+ }
$this->set_mapping('wiki_subwiki', $oldid, $newitemid);
}
protected function process_wiki_page($data) {
@@ -91,7 +95,11 @@ protected function process_wiki_page($data) {
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timerendered = $this->apply_date_offset($data->timerendered);
- $newitemid = $DB->insert_record('wiki_pages', $data);
+ if($data->subwikiid !== false) {
+ $newitemid = $DB->insert_record('wiki_pages', $data);
+ } else {
+ $newitemid = false;
+ }
$this->set_mapping('wiki_page', $oldid, $newitemid, true); // There are files related to this
}
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.