Skip to content

Commit

Permalink
Add a deprecation warning if downstream applications have used #solr_…
Browse files Browse the repository at this point in the history
…doc_params to add search parameters
  • Loading branch information
cbeer committed Dec 10, 2014
1 parent b057627 commit fba2ef4
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions lib/blacklight/solr_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,7 @@ def find *args

# returns a params hash for finding a single solr document (CatalogController #show action)
def solr_doc_params(id=nil)
id ||= params[:id]

# add our document id to the document_unique_id_param query parameter
p = blacklight_config.default_document_solr_params.merge({
# this assumes the request handler will map the unique id param
# to the unique key field using either solr local params, the
# real-time get handler, etc.
blacklight_config.document_unique_id_param => id
})

p[:qt] ||= blacklight_config.document_solr_request_handler

p
default_solr_doc_params(id=nil)
end
deprecation_deprecate :solr_doc_params

Expand Down Expand Up @@ -120,6 +108,16 @@ def get_solr_response_for_doc_id(id=nil, extra_controller_params={})
Deprecation.warn Blacklight::SolrHelper, "Calling #get_solr_response_for_doc_id without an explicit id argument is deprecated"
id ||= params[:id]
end

old_solr_doc_params = Deprecation.silence(Blacklight::SolrHelper) do
solr_doc_params(id)
end

if default_solr_doc_params(id) != old_solr_doc_params
Deprecation.warn Blacklight::SolrHelper, "The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering"
extra_controller_params = extra_controller_params.merge(old_solr_doc_params)
end

solr_response = solr_repository.find id, extra_controller_params
[solr_response, solr_response.documents.first]
end
Expand Down Expand Up @@ -238,4 +236,24 @@ def solr_repository
@solr_repository ||= Blacklight::SolrRepository.new(blacklight_config)
end

private

##
# @deprecated
def default_solr_doc_params(id=nil)
id ||= params[:id]

# add our document id to the document_unique_id_param query parameter
p = blacklight_config.default_document_solr_params.merge({
# this assumes the request handler will map the unique id param
# to the unique key field using either solr local params, the
# real-time get handler, etc.
blacklight_config.document_unique_id_param => id
})

p[:qt] ||= blacklight_config.document_solr_request_handler

p
end

end

0 comments on commit fba2ef4

Please sign in to comment.