Permalink
Browse files

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

… an error on restore
  • Loading branch information...
salmonmoose authored and markn86 committed Oct 4, 2013
1 parent 67d4599 commit 84c3f002eab2c5d2181c755a6df7f26e43ba35f5
Showing with 12 additions and 4 deletions.
  1. +12 −4 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 84c3f00

Please sign in to comment.