Skip to content

A platform for community discussion. Free, open, simple.

FIX: Make themes:update work with multisites (#14082)

Dan Ungureanuc0ec1e931e4c
diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake
index 51746bd268b..1e2fdfacc03 100644
--- a/lib/tasks/themes.rake
+++ b/lib/tasks/themes.rake
@@ -52,21 +52,20 @@ task "themes:install" => :environment do |task, args|
end
end
-desc "Update themes & theme components"
-task "themes:update" => :environment do |task, args|
+def update_themes
Theme.where(auto_update: true, enabled: true).find_each do |theme|
begin
if theme.remote_theme.present?
- puts "Updating #{theme.name}..."
+ puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."
theme.remote_theme.update_from_remote
theme.save!
unless theme.remote_theme.last_error_text.nil?
- puts "Error updating #{theme.name}: #{theme.remote_theme.last_error_text}"
+ puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
exit 1
end
end
rescue => e
- STDERR.puts "Failed to update #{theme.name}"
+ STDERR.puts "Failed to update '#{theme.name}'"
STDERR.puts e
STDERR.puts e.backtrace
exit 1
@@ -74,6 +73,17 @@ task "themes:update" => :environment do |task, args|
end
end
+desc "Update themes & theme components"
+task "themes:update" => :environment do
+ if ENV['RAILS_DB'].present?
+ update_themes
+ else
+ RailsMultisite::ConnectionManagement.each_connection do
+ update_themes
+ end
+ end
+end
+
desc "List all the installed themes on the site"
task "themes:audit" => :environment do
components = Set.new