From 21a356e3af34f15234d09cbe0e4bdb3eff408f5d Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 15 Feb 2022 08:51:42 +1000 Subject: [PATCH] FIX: Post migration to fix custom emojis with secure URL Follow up to 88a8584348ed93a28286839bfc1c32b06bd50b3f. Sets the baked version of all posts with custom emoji and a secure media URL in the cooked content to 0. Then our periodic rebake posts job will rebake them to apply the fix in the linked commit. This only matters on sites with secure media enabled. --- ...custom_emoji_post_bakes_version_secure_fix.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb diff --git a/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb b/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb new file mode 100644 index 00000000000..950794b7456 --- /dev/null +++ b/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class ResetCustomEmojiPostBakesVersionSecureFix < ActiveRecord::Migration[6.1] + def up + if SiteSetting.secure_media + execute <<~SQL + UPDATE posts SET baked_version = 0 + WHERE cooked LIKE '%emoji emoji-custom%' AND cooked LIKE '%secure-media-uploads%' + SQL + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end