From b6bbfb907cc1acdd554ce5d6bc0730bfb06b6a6b Mon Sep 17 00:00:00 2001 From: Jens Maier Date: Wed, 1 Oct 2014 13:36:26 +0200 Subject: [PATCH] FIX: quoting non-existing messages would break SMF2 importer --- lib/pretty_text.rb | 2 +- script/import_scripts/smf2.rb | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 500c5d888e8..2cbefe1e378 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -8,7 +8,7 @@ module PrettyText class Helpers def t(key, opts) - str = I18n.t("js." + key) + str = I18n.t("js." + key, opts) if opts # TODO: server localisation has no parity with client should be fixed str = str.dup diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rb index b010aa3e78d..e657fac4d28 100644 --- a/script/import_scripts/smf2.rb +++ b/script/import_scripts/smf2.rb @@ -421,7 +421,7 @@ class ImportScripts::Smf2 < ImportScripts::Base quote = "[quote=\"#{params['author']}" if QuoteParamsPattern =~ params['link'] tl = topic_lookup_from_imported_post_id($~[:msg].to_i) - quote << ", post:#{tl[:post_number]}, topic:#{tl[:topic_id]}" + quote << ", post:#{tl[:post_number]}, topic:#{tl[:topic_id]}" if tl end quote << "\"]#{inner}[/quote]" else @@ -606,7 +606,7 @@ class ImportScripts::Smf2 < ImportScripts::Base end def quoted - @quoted.map {|id| @graph[id] } + @quoted.map {|id| @graph[id] }.reject(&:nil?) end def ignore_quotes? @@ -634,7 +634,13 @@ class ImportScripts::Smf2 < ImportScripts::Base end def inspect - "#<#{self.class.name}: id=#{id.inspect}, prev=#{prev.try(:id).inspect}, quoted=#{quoted.map{|e|e.id}.inspect}>" + "#<#{self.class.name}: id=#{id.inspect}, prev=#{safe_id(@prev)}, quoted=[#{@quoted.map(&method(:safe_id)).join(', ')}]>" + end + + private + + def safe_id(id) + @graph[id].present? ? @graph[id].id.inspect : "(#{id})" end end #Node