summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-01-30 20:47:23 +0000
committerRobert Speicher <robert@gitlab.com>2018-01-30 20:47:23 +0000
commit95b4f7ea37d641c7c30e9903dd3390a7d04a6e67 (patch)
tree9abac8cc851f8249a0b0279f1406d8f6fe9cdaad /app
parenta20e02a5bc2e52f679ee220f61abeb9ecfff1ec9 (diff)
parentfa9d47f221fff4d75e3c50670aeeac7a3d675f7a (diff)
downloadgitlab-ce-95b4f7ea37d641c7c30e9903dd3390a7d04a6e67.tar.gz
Merge branch 'feature/migrate-wiki-page-formatted-data-to-gitaly' into 'master'
Migrate fetching wiki page formatted content to Gitaly Closes gitaly#958 See merge request gitlab-org/gitlab-ce!16716
Diffstat (limited to 'app')
-rw-r--r--app/models/project_wiki.rb6
-rw-r--r--app/models/wiki_page.rb5
2 files changed, 10 insertions, 1 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index a0af749a93f..459d1673125 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -124,6 +124,12 @@ class ProjectWiki
update_project_activity
end
+ def page_formatted_data(page)
+ page_title, page_dir = page_title_and_dir(page.title)
+
+ wiki.page_formatted_data(title: page_title, dir: page_dir, version: page.version)
+ end
+
def page_title_and_dir(title)
title_array = title.split("/")
title = title_array.pop
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index bdfef677ef3..e6254183baf 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -107,7 +107,10 @@ class WikiPage
# The processed/formatted content of this page.
def formatted_content
- @attributes[:formatted_content] ||= @page&.formatted_data
+ # Assuming @page exists, nil formatted_data means we didn't load it
+ # before hand (i.e. page was fetched by Gitaly), so we fetch it separately.
+ # If the page was fetched by Gollum, formatted_data would've been a String.
+ @attributes[:formatted_content] ||= @page&.formatted_data || @wiki.page_formatted_data(@page)
end
# The markup format for the page.