From 8d9b5ed70a3ac9ed53ef8e042e9dc99283816691 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Wed, 26 Apr 2017 01:04:59 +0200 Subject: [PATCH] phpBB3 importer: Disable file size validators during import --- script/import_scripts/phpbb3/importer.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/script/import_scripts/phpbb3/importer.rb b/script/import_scripts/phpbb3/importer.rb index b9daaa15687..dfaa21951b0 100644 --- a/script/import_scripts/phpbb3/importer.rb +++ b/script/import_scripts/phpbb3/importer.rb @@ -34,9 +34,32 @@ module ImportScripts::PhpBB3 end def change_site_settings + # let's make sure that we import all attachments no matter how big they are + setting_keys = [:max_image_size_kb, :max_attachment_size_kb] + original_validators = disable_setting_validators(setting_keys) + super @importers.permalink_importer.change_site_settings + + enable_setting_validators(original_validators) + end + + def disable_setting_validators(setting_keys) + original_validators = {} + + setting_keys.each do |key| + original_validators[key] = SiteSetting.validators[key] + SiteSetting.validators[key] = nil + end + + original_validators + end + + def enable_setting_validators(original_validators) + original_validators.each do |key, validator| + SiteSetting.validators[key] = validator + end end def get_site_settings_for_import