diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-29 00:09:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-29 00:09:15 +0300 |
commit | 8831c2df7fa3f1bb567e284e4b8c0a4f441e74b3 (patch) | |
tree | 36b1b430075ff6e63524be14585dbb614e893e8c /app/models/concerns | |
parent | 1c8fa70f9d0818e2a82089c8643a6e455bca47fd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/cache_markdown_field.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb index 9713e79f525..cc13f279c4d 100644 --- a/app/models/concerns/cache_markdown_field.rb +++ b/app/models/concerns/cache_markdown_field.rb @@ -20,6 +20,10 @@ module CacheMarkdownField false end + def can_cache_field?(field) + true + end + # Returns the default Banzai render context for the cached markdown field. def banzai_render_context(field) raise ArgumentError.new("Unknown field: #{field.inspect}") unless @@ -38,17 +42,23 @@ module CacheMarkdownField context end - # Update every column in a row if any one is invalidated, as we only store - # one version per row - def refresh_markdown_cache + def rendered_field_content(markdown_field) + return unless can_cache_field?(markdown_field) + options = { skip_project_check: skip_project_check? } + Banzai::Renderer.cacheless_render_field(self, markdown_field, options) + end + # Update every applicable column in a row if any one is invalidated, as we only store + # one version per row + def refresh_markdown_cache updates = cached_markdown_fields.markdown_fields.map do |markdown_field| [ cached_markdown_fields.html_field(markdown_field), - Banzai::Renderer.cacheless_render_field(self, markdown_field, options) + rendered_field_content(markdown_field) ] end.to_h + updates['cached_markdown_version'] = latest_cached_markdown_version updates.each { |field, data| write_markdown_field(field, data) } |