Commit eee9abe4 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch '197908-nomethoderror-undefined-method-without_count-for-kaminari-paginatablearray' into 'master'

Fix 500 error in global & group search for blob, wiki_blob and commit search

Closes #197908

See merge request gitlab-org/gitlab!23326
parents b04383b9 9a56deac
---
title: Fix 500 error in global search for blob, wiki_blob and commit search
merge_request: 23326
author:
type: fixed
......@@ -12,14 +12,14 @@ module EE
ELASTICSEARCH_SCOPES = %w(wiki_blobs blobs commits).freeze
override :verify_search_scope!
def verify_search_scope!
if ELASTICSEARCH_SCOPES.include?(params[:scope]) && !elasticsearch?
def verify_search_scope!(resource:)
if ELASTICSEARCH_SCOPES.include?(params[:scope]) && !use_elasticsearch?(resource)
render_api_error!({ error: 'Scope not supported without Elasticsearch!' }, 400)
end
end
def elasticsearch?
::Gitlab::CurrentSettings.elasticsearch_search?
def use_elasticsearch?(resource)
::Gitlab::CurrentSettings.search_using_elasticsearch?(scope: resource)
end
override :process_results
......
This diff is collapsed.
......@@ -47,7 +47,7 @@ module API
SCOPE_ENTITY[params[:scope].to_sym]
end
def verify_search_scope!
def verify_search_scope!(resource:)
# In EE we have additional validation requirements for searches.
# Defining this method here as a noop allows us to easily extend it in
# EE, without having to modify this file directly.
......@@ -73,7 +73,7 @@ module API
use :pagination
end
get do
verify_search_scope!
verify_search_scope!(resource: nil)
check_users_search_allowed!
present search, with: entity
......@@ -94,7 +94,7 @@ module API
use :pagination
end
get ':id/(-/)search' do
verify_search_scope!
verify_search_scope!(resource: user_group)
check_users_search_allowed!
present search(group_id: user_group.id), with: entity
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment