]> BookStack Code Mirror - bookstack/commitdiff
Fixed issue where updated page content would not be indexed
authorDan Brown <redacted>
Fri, 22 May 2020 23:46:13 +0000 (00:46 +0100)
committerDan Brown <redacted>
Fri, 22 May 2020 23:46:13 +0000 (00:46 +0100)
- Also updated html field of pages to not be fillable.
   (Since HTML should always go through app id parsing)

Related to #2042

app/Entities/Page.php
app/Entities/Repos/PageRepo.php
tests/Entity/EntitySearchTest.php

index d10786ddac18177f99197939065d4d3f3033c59f..32ba2981d807e7a2b2b7a35c7984e523a82448ca 100644 (file)
@@ -21,7 +21,7 @@ use Permissions;
  */
 class Page extends BookChild
 {
-    protected $fillable = ['name', 'html', 'priority', 'markdown'];
+    protected $fillable = ['name', 'priority', 'markdown'];
 
     protected $simpleAttributes = ['name', 'id', 'slug'];
 
index d92085a61cf4c786f9c2f0c6210e9363cf8f5611..fc585b4dff9921f89e890b54a88350690228464d 100644 (file)
@@ -180,12 +180,11 @@ class PageRepo
             $page->template = ($input['template'] === 'true');
         }
 
+        $pageContent = new PageContent($page);
+        $pageContent->setNewHTML($input['html']);
         $this->baseRepo->update($page, $input);
 
         // Update with new details
-        $page->fill($input);
-        $pageContent = new PageContent($page);
-        $pageContent->setNewHTML($input['html']);
         $page->revision_count++;
 
         if (setting('app-editor') !== 'markdown') {
index 72eb808dc4c581a84e03d85c74366ee79d3b238a..956e46c3713d4785cd7b8dcd11589cc6988dcfb0 100644 (file)
@@ -277,4 +277,20 @@ class EntitySearchTest extends TestCase
             $search->assertSee($expectedShelf->name);
         }
     }
+
+    public function test_search_works_on_updated_page_content()
+    {
+        $page = Page::query()->first();
+        $this->asEditor();
+
+        $update = $this->put($page->getUrl(), [
+            'name' => $page->name,
+            'html' => '<p>dog pandabearmonster spaghetti</p>',
+        ]);
+
+        $search = $this->asEditor()->get('/search?term=pandabearmonster');
+        $search->assertStatus(200);
+        $search->assertSeeText($page->name);
+        $search->assertSee($page->getUrl());
+    }
 }