Before this change, if Gitlab.config.gitlab_on_non_standard_port? returned false then default_url_options[:port] would fall back to using the value set in your current environment file in config.action_mailer.default_url_options. That value is actually set in the config/environments/development.rb file.

So if you had set gitlab.port to 80 (a standard port) in your gitlab.yml, but had config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } in your environment file, the port chosen by the existing code would be 3000.

The change makes sure that default_url_options[:port] is either assigned here or set to nil.