diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 14564a38d21..a2d6f11afb1 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -106,7 +106,8 @@ class StaticController < ApplicationController
file.unlink
data
rescue => e
- Rails.logger.warn("Invalid favicon_url #{SiteSetting.favicon_url}: #{e}\n#{e.backtrace}")
+ AdminDashboardData.add_problem_message('dashboard.bad_favicon_url', 1800)
+ Rails.logger.debug("Invalid favicon_url #{SiteSetting.favicon_url}: #{e}\n#{e.backtrace}")
""
end
end
diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb
index 9f2bfad63e7..6a492ac9bb9 100644
--- a/app/models/admin_dashboard_data.rb
+++ b/app/models/admin_dashboard_data.rb
@@ -37,7 +37,7 @@ class AdminDashboardData
@problem_syms.push(*syms) if syms
@problem_blocks << blk if blk
end
- class << self; attr_reader :problem_syms, :problem_blocks; end
+ class << self; attr_reader :problem_syms, :problem_blocks, :problem_messages; end
def problems
problems = []
@@ -47,6 +47,9 @@ class AdminDashboardData
AdminDashboardData.problem_blocks.each do |blk|
problems << instance_exec(&blk)
end
+ AdminDashboardData.problem_messages.each do |i18n_key|
+ problems << AdminDashboardData.problem_message_check(i18n_key)
+ end
problems.compact
end
@@ -54,6 +57,7 @@ class AdminDashboardData
def self.reset_problem_checks
@problem_syms = []
@problem_blocks = []
+ @problem_messages = ['dashboard.bad_favicon_url']
add_problem_check :rails_env_check, :ruby_version_check, :host_names_check,
:gc_checks, :ram_check, :google_oauth2_config_check,
@@ -83,6 +87,26 @@ class AdminDashboardData
AdminDashboardData.new.problems
end
+ def self.problem_message_check(i18n_key)
+ $redis.get(problem_message_key(i18n_key)) ? I18n.t(i18n_key) : nil
+ end
+
+ def self.add_problem_message(i18n_key, expire_seconds=nil)
+ if expire_seconds.to_i > 0
+ $redis.setex problem_message_key(i18n_key), expire_seconds.to_i, 1
+ else
+ $redis.set problem_message_key(i18n_key), 1
+ end
+ end
+
+ def self.clear_problem_message(i18n_key)
+ $redis.del problem_message_key(i18n_key)
+ end
+
+ def self.problem_message_key(i18n_key)
+ "admin-problem:#{i18n_key}"
+ end
+
def as_json(_options = nil)
@json ||= {
global_reports: AdminDashboardData.reports(GLOBAL_REPORTS),
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 77a7508394f..3fa0922f16b 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -790,6 +790,7 @@ en:
email_polling_errored_recently:
one: "Email polling has generated an error in the past 24 hours. Look at the logs for more details."
other: "Email polling has generated %{count} errors in the past 24 hours. Look at the logs for more details."
+ bad_favicon_url: "The favicon is failing to load. Check your favicon_url setting in Site Settings."
site_settings:
censored_words: "Words that will be automatically replaced with ■■■■"
diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb
index f15a7b2bad1..507518a36c1 100644
--- a/spec/models/admin_dashboard_data_spec.rb
+++ b/spec/models/admin_dashboard_data_spec.rb
@@ -278,4 +278,26 @@ describe AdminDashboardData do
include_examples 'stats cachable'
end
+ describe '#problem_message_check' do
+ let(:key) { AdminDashboardData.problem_messages.first }
+
+ before do
+ described_class.clear_problem_message(key)
+ end
+
+ it 'returns nil if message has not been added' do
+ expect(described_class.problem_message_check(key)).to be_nil
+ end
+
+ it 'returns a message if it was added' do
+ described_class.add_problem_message(key)
+ expect(described_class.problem_message_check(key)).to eq(I18n.t(key))
+ end
+
+ it 'returns a message if it was added with an expiry' do
+ described_class.add_problem_message(key, 300)
+ expect(described_class.problem_message_check(key)).to eq(I18n.t(key))
+ end
+ end
+
end