about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authoralpaca-tc <alpaca-tc@alpaca.tc>2017-05-13 22:56:12 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-13 15:56:12 +0200
commite9810cbad61625771c4d0a8de25211795f03d82e (patch)
tree1e0b7c8965ec382061fd926a611696009ff28e95 /app
parent1027556614febb096f2186d3c678116b415c0b9b (diff)
Fixes NoMethodError: undefined method 'first' for nil:NilClass (#3036)
Diffstat (limited to 'app')
-rw-r--r--app/models/status.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 14c6dd9f6..772cef238 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -124,7 +124,7 @@ class Status < ApplicationRecord
   def ancestors(account = nil)
     ids      = Rails.cache.fetch("ancestors:#{id}") { (Status.find_by_sql(['WITH RECURSIVE search_tree(id, in_reply_to_id, path) AS (SELECT id, in_reply_to_id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, statuses.in_reply_to_id, path || statuses.id FROM search_tree JOIN statuses ON statuses.id = search_tree.in_reply_to_id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path DESC', id]) - [self]).pluck(:id) }
     statuses = Status.where(id: ids).group_by(&:id)
-    results  = ids.map { |id| statuses[id].first }
+    results  = ids.map { |id| statuses[id]&.first }.compact
     results  = results.reject { |status| filter_from_context?(status, account) }
 
     results