From aa8b5e94d3edcc65e5b7b35afbaee4d7af0c629a Mon Sep 17 00:00:00 2001
From: Matt Kasa <mkasa@gitlab.com>
Date: Wed, 26 Jan 2022 19:32:36 -0800
Subject: [PATCH] Fix use of ActiveRecord::Base in RepositoryCheck

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/350651
---
 .rubocop_todo/database/multiple_databases.yml | 1 -
 lib/system_check/orphans/repository_check.rb  | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/.rubocop_todo/database/multiple_databases.yml b/.rubocop_todo/database/multiple_databases.yml
index 28dddef7c79b..30e36802c42e 100644
--- a/.rubocop_todo/database/multiple_databases.yml
+++ b/.rubocop_todo/database/multiple_databases.yml
@@ -25,7 +25,6 @@ Database/MultipleDatabases:
   - lib/gitlab/import_export/group/relation_tree_restorer.rb
   - lib/gitlab/legacy_github_import/importer.rb
   - lib/gitlab/seeder.rb
-  - lib/system_check/orphans/repository_check.rb
   - spec/db/schema_spec.rb
   - spec/initializers/database_config_spec.rb
   - spec/lib/backup/manager_spec.rb
diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb
index 33020417e95c..8f15872de228 100644
--- a/lib/system_check/orphans/repository_check.rb
+++ b/lib/system_check/orphans/repository_check.rb
@@ -57,8 +57,8 @@ def fetch_repositories(storage_name)
           WHERE (p.repository_storage LIKE ?)
         "
 
-        query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, storage_name]) # rubocop:disable GitlabSecurity/PublicSend
-        ActiveRecord::Base.connection.select_all(query).rows.try(:flatten!) || []
+        query = ::Project.sanitize_sql_array([sql, storage_name])
+        ::Project.connection.select_all(query).rows.try(:flatten!) || []
       end
 
       def fetch_disk_namespaces(storage_path)
-- 
GitLab