From f4d833da27e55b2ba350e7755c29add60143c67e Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 20 Aug 2013 11:38:10 +1000 Subject: [PATCH] fix onebox exception, if oneboxes fail on save we log a warning to the log --- app/models/post_analyzer.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/post_analyzer.rb b/app/models/post_analyzer.rb index 533c0eda7a8..0ad69f34af4 100644 --- a/app/models/post_analyzer.rb +++ b/app/models/post_analyzer.rb @@ -9,11 +9,18 @@ class PostAnalyzer def cook(*args) cooked = PrettyText.cook(*args) - # If we have any of the oneboxes in the cache, throw them in right away, don't - # wait for the post processor. + # cook all oneboxes, in the past we used to defer this + # for some reason we decided to do this inline now + # TODO: discuss on http://meta.discourse.org what the correct thing is to do + # keep in mind some oneboxes may take a long time to build result = Oneboxer.apply(cooked) do |url, elem| Oneboxer.invalidate(url) if args.last[:invalidate_oneboxes] - Oneboxer.onebox url + begin + Oneboxer.onebox url + rescue => e + Rails.logger.warn("Failed to cook onebox: #{e.message} #{e.backtrace}") + nil + end end cooked = result.to_html if result.changed?