Merge pull request #10092 from opf/fix/40790/missing-menu-item

[40790] Fix missing menu_item in wiki items controller
pull/10093/head
Oliver Günther 3 years ago committed by GitHub
commit f3210839e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/controllers/wiki_controller.rb
  2. 4
      app/controllers/wiki_menu_items_controller.rb

@ -341,13 +341,13 @@ class WikiController < ApplicationController
page = page_for_menu_item(page) page = page_for_menu_item(page)
menu_item = page.try(:menu_item) menu_item = page.try(:menu_item)
return menu_item.menu_identifier if menu_item.present?
return unless page
if menu_item.present? default_item = default_menu_item(page)
menu_item.menu_identifier return unless default_item
elsif page.present?
menu_item = default_menu_item(page) "no-menu-item-#{default_item.menu_identifier}".to_sym
"no-menu-item-#{menu_item&.menu_identifier || 'unknown'}".to_sym
end
end end
private private

@ -34,7 +34,7 @@ class WikiMenuItemsController < ApplicationController
include Redmine::MenuManager::WikiMenuHelper include Redmine::MenuManager::WikiMenuHelper
current_menu_item :edit do |controller| current_menu_item :edit do |controller|
next controller.wiki_menu_item.menu_identifier if controller.wiki_menu_item.persisted? next controller.wiki_menu_item.menu_identifier if controller.wiki_menu_item.try(:persisted?)
project = controller.instance_variable_get(:@project) project = controller.instance_variable_get(:@project)
if (page = WikiPage.find_by(wiki_id: project.wiki.id, slug: controller.params[:id])) if (page = WikiPage.find_by(wiki_id: project.wiki.id, slug: controller.params[:id]))
@ -52,6 +52,8 @@ class WikiMenuItemsController < ApplicationController
def self.default_menu_item(controller, page) def self.default_menu_item(controller, page)
menu_item = controller.default_menu_item(page) menu_item = controller.default_menu_item(page)
return unless menu_item
"no-menu-item-#{menu_item.menu_identifier}".to_sym "no-menu-item-#{menu_item.menu_identifier}".to_sym
end end

Loading…
Cancel
Save