MDl-33607 wiki-2: check subwiki before fetching it from db
authorRajesh Taneja <rajesh@moodle.com>
Fri, 15 Jun 2012 08:43:01 +0000 (16:43 +0800)
committerRajesh Taneja <rajesh@moodle.com>
Mon, 18 Jun 2012 02:20:29 +0000 (10:20 +0800)
mod/wiki/pagelib.php

index a24d877..1652371 100644 (file)
@@ -946,9 +946,12 @@ class page_wiki_create extends page_wiki {
         } else {
             $groupid = '0';
         }
-        if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid)) {
-            $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
-            $this->subwiki = wiki_get_subwiki($swid);
+        if (empty($this->subwiki)) {
+            // If subwiki is not set then try find one and set else create one.
+            if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid)) {
+                $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
+                $this->subwiki = wiki_get_subwiki($swid);
+            }
         }
         if ($data) {
             $this->set_title($data->pagetitle);