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

check current_user is defined in agent_is crawler #2488

Merged
merged 1 commit into from
Oct 21, 2021

Conversation

kosarko
Copy link
Contributor

@kosarko kosarko commented Sep 22, 2021

I did as suggested in #1736 (comment) to disable search tracking, ie config.crawler_detector = lambda { |req| true }, but that resulted in:

NameError in CatalogController#index
undefined local variable or method `current_user' for #<CatalogController:0x0000000000ceb8>

Did you mean?
current_or_guest_user
Extracted source (around line #76):
              
74  def agent_is_crawler?
75    crawler_proc = blacklight_config.crawler_detector
76    return false if crawler_proc.nil? || current_user.present?
77
78    crawler_proc.call(request)
79  end

Rails.root: /src/blacklightapp

Application Trace | Framework Trace | Full Trace
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:76:in `agent_is_crawler?'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:41:in `find_search_session'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:32:in `current_search_session'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:37:in `set_current_search_session'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:427:in `block in make_lambda'

I've installed blacklight without devise, I have no need for users logging in, yet.
The patch seems to fix the issue, it just checks something called current_user is defined...

I did as suggested in projectblacklight#1736 (comment) to disable search tracking, ie `config.crawler_detector = lambda { |req| true }`, but that resulted in:
```
NameError in CatalogController#index
undefined local variable or method `current_user' for #<CatalogController:0x0000000000ceb8>

Did you mean?
current_or_guest_user
Extracted source (around line projectblacklight#76):
              
74  def agent_is_crawler?
75    crawler_proc = blacklight_config.crawler_detector
76    return false if crawler_proc.nil? || current_user.present?
77
78    crawler_proc.call(request)
79  end

Rails.root: /src/blacklightapp

Application Trace | Framework Trace | Full Trace
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:76:in `agent_is_crawler?'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:41:in `find_search_session'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:32:in `current_search_session'
blacklight (7.13.2) app/controllers/concerns/blacklight/search_context.rb:37:in `set_current_search_session'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:427:in `block in make_lambda'
```
I've installed blacklight without devise, I have no need for users logging in, yet.
The patch seems to fix the issue, it just checks something called `current_user` is defined...
@bess bess added this to the Oct 11 - 22 🕸 milestone Oct 14, 2021
@bess bess merged commit bfc80ff into projectblacklight:master Oct 21, 2021
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

Successfully merging this pull request may close these issues.

2 participants