Top Menu Removal Crashes Site


(charles) #1

It seems if I remove each item for top menu, save and then try to refresh the main page, it “crashes” and gives me a blank page. If I then go back and reset, the blank page goes back to regular view.

Anyone else having this issue using the latest build?


Crashed my discourse while changing settings in admin section
(Mittineague) #2

Exactly what are you removing and how ?

What error message(s) does the console show ?


(charles) #3

Under basic setup, I was removing all the items listed under top menu

I’m guessing it “crashes” because when the menu item ‘latest’ is removed, there is no view to show?


(Mittineague) #4

Well, you didn’t answer my questions so I can only guess.

You are not removing by using CSS display none, but are emptying this Admin -> Settings -> Basic Setup input ?

top menu

Determine which items appear in the homepage navigation, and in what order. Example latest|new|unread|categories|top|read|posted|bookmarks

This being empty is not really a Bug as it isn’t normal to have no navigation.

But I think it might be a good idea to force it to have at least one. Or if not that, maybe include a Warning in the copy.

TBH I don’t know how many Warnings Discourse should have. It could make things quite noisy to have a lot of “if you do this weird unusual thing there will be breakage” warnings all over the place.


(charles) #5

Sorry I didn’t answer about the error from console. How can I obtain that for you?


(Mittineague) #6

AFAIK most browsers it’s under "tools"
But it might be easier to press F12

Once the dev tools open if it isn’t already open to “console” go to it, reload the page and any JavaScript errors and other messages should show there.


(charles) #7

The only item that shows up is

Get http://example.com/ HTTP/1.1 500 Internal Server Error 25ms

As you mentioned it’s not a bug. I will simply reset and instead use CSS display none for category-breadcrumb and the nav-pills

Thanks for looking into it.


(Jnns) #8

Being able to empty the settings field and the app logic relying on at least one value being present is most definitely a bug as it renders the site inaccessible (at least the index, that is)!

I emptied the settings field and upon the next login was greeted with just an HTTP500 error with no clue on how to resolve this. Only after digging through the logs of the Docker container, finding this:

Redirected to https://discourse.example.com/
Completed 302 Found in 18ms (ActiveRecord: 4.6ms)
Started GET "/" for xxx.xxx.xxx.xxx at 2017-01-26 12:39:52 +0000
NoMethodError (undefined method `name' for nil:NilClass)
/var/www/discourse/app/models/site_setting.rb:65:in `homepage'

and reading up on in in the source code on GitHub

def self.top_menu_items
 top_menu.split('|').map { |menu_item| TopMenuItem.new(menu_item) }
end

def self.homepage
  top_menu_items[0].name
end

then I tried to open up the admin panel and was able to set a default value for top_menu_items again.

There needs to be a way to prevent the user from deleting all top_menu_items or a check for an empty setting so that the site keeps being functional.