Skip to content

Commit

Permalink
Provide a deprecation for calling show_fields_for with a scalar value
Browse files Browse the repository at this point in the history
It should be called with an Array.  I found this bug when upgrading Argo, which called show_fields_for with a Symbol.  This no longer worked in Blacklight 8

Fixes #2934
  • Loading branch information
jcoyne committed Dec 13, 2022
1 parent e917712 commit 7ec18a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,13 @@ def show_fields_for(document_or_display_types)
document_or_display_types
end

if !display_types.respond_to?(:each)
Deprecation.warn self, "Calling show_fields_for with a scalar value is deprecated. It must receive an Enumerable."
display_types = Array.wrap(display_types)
end
fields = {}.with_indifferent_access

Array.wrap(display_types).each do |display_type|
display_types.each do |display_type|
fields = fields.merge(for_display_type(display_type).show_fields)
end

Expand Down

0 comments on commit 7ec18a3

Please sign in to comment.