diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 496f1499..bdf0a692 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -52,11 +52,13 @@ class WikiPage public string $title; public int $revision; public bool $locked; + public bool $exists; public string $body; public function __construct(array $row=null) { //assert(!empty($row)); + global $database; if (!is_null($row)) { $this->id = (int)$row['id']; @@ -66,6 +68,7 @@ class WikiPage $this->title = $row['title']; $this->revision = (int)$row['revision']; $this->locked = bool_escape($row['locked']); + $this->exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title"=>$this->title]); $this->body = $row['body']; } } @@ -79,6 +82,11 @@ class WikiPage { return $this->locked; } + + public function exists(): bool + { + return $this->exists; + } } abstract class WikiConfig diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index f68623cc..39e52505 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -35,6 +35,10 @@ class WikiTheme extends Themelet $title_html = $this->tagcategories->getTagHtml($title_html, $tag_category_dict); } + if (!$wiki_page->exists) { + $page->set_code(404); + } + $page->set_title(html_escape($wiki_page->title)); $page->set_heading(html_escape($wiki_page->title)); $page->add_block(new NavBlock());