Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning for @document #83

Open
cdmo opened this issue Oct 3, 2019 · 1 comment
Open

Deprecation warning for @document #83

cdmo opened this issue Oct 3, 2019 · 1 comment

Comments

@cdmo
Copy link
Member

cdmo commented Oct 3, 2019

I'm seeing a number of deprecation warnings in the Rails log surrounding @document which was deprecated here

DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)

I am not sure how this can be fixed. I tried the following, but just got new warnings:

diff --git a/lib/blacklight/marc/catalog.rb b/lib/blacklight/marc/catalog.rb
index 29b3830..8508cbc 100644
--- a/lib/blacklight/marc/catalog.rb
+++ b/lib/blacklight/marc/catalog.rb
@@ -22,15 +22,15 @@ module Blacklight::Marc
     private

     def render_refworks_action? config, options = {}
-      options[:document] && options[:document].respond_to?(:export_formats) && options[:document].export_formats.keys.include?(:refworks_marc_txt )
+      @response.docs.first && @response.docs.first.respond_to?(:export_formats) && @response.docs.first.export_formats.keys.include?(:refworks_marc_txt )
     end

     def render_endnote_action? config, options = {}
-      options[:document] && options[:document].respond_to?(:export_formats) && options[:document].export_formats.keys.include?(:endnote )
+      @response.docs.first && @response.docs.first.respond_to?(:export_formats) && @response.docs.first.export_formats.keys.include?(:endnote )
     end

     def render_librarian_view_control? config, options = {}
-      respond_to? :librarian_view_solr_document_path and options[:document] and options[:document].respond_to?(:to_marc)
+      respond_to? :librarian_view_solr_document_path and @response.docs.first and @response.docs.first.respond_to?(:to_marc)
     end

   end

And the warning here was:

DEPRECATION WARNING: The @response instance variable is deprecated; use @document.response instead. (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)

This is the whole list of deprecation warning I am seeing when I am using Blacklight 7.1.0 with blacklight-marc:

DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from single_endnote_catalog_path at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/app/helpers/blacklight_marc_helper.rb:16)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_refworks_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:25)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from render_endnote_action? at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/lib/blacklight/marc/catalog.rb:29)
DEPRECATION WARNING: The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0 (called from single_endnote_catalog_path at /Users/cdm32/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/blacklight-marc-c0ff1d9cb5d3/app/helpers/blacklight_marc_helper.rb:16)
@cdmo
Copy link
Member Author

cdmo commented May 28, 2020

I'm starting to wonder, looking at this again today with fresh eyes, if maybe this deprecation was done in error. If you look at Blacklight::Catalog#show it deprecates @response, see https://github.com/projectblacklight/blacklight/blob/master/app/controllers/concerns/blacklight/catalog.rb#L47-L48 as it is returned from search_service.fetch(params[:id]) - @document is still ok to use in the catalog#show context (what these view partials in this repo inherit)

This is different from Blacklight::Catalog#index which deprecates @document_list (as returned from search_service.search_results).

Another indicator to me is that Blacklight proper is still using @document in show partials, like this one: https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_show_main_content.html.erb

So am wondering if we can revert this commit e9b8c60 @jcoyne? Is this making sense? Wanted to run it by you first before putting in a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant