Skip to content

Blacklight 9: SingleDocSearchBuilder gets a Blacklight::Solr::Repository as its first argument, should get a Controller #3792

@sandbergja

Description

@sandbergja

When on a record show page, Blacklight::Solr::Repository#fetch creates a new SingleDocSearchBuilder. The first argument is self, that is to say, an instance of Blacklight::Solr::Repository:

doc_params = SingleDocSearchBuilder.new(self, id, params)

SingleDocSearchBuilder calls super on that first argument:

And we then try to use it to create a Blacklight::SearchState or similar, as the third argument:

@search_state = search_state_class.new(@blacklight_params, @scope&.blacklight_config, @scope)

But yikes, the third argument to Blacklight::SearchState's constructor is supposed to be a controller, not a solr repository:

def initialize(params, blacklight_config, controller = nil)

This doesn't cause trouble in stock blacklight, but if you have customized the search builder to include something that relies on, say search_state.controller&.action_name, you will get

*** NoMethodError Exception: undefined method 'action_name' for an instance of Blacklight::Solr::Repository

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions