From 0d0740ffb1075a8f65841aa66e913025cad58403 Mon Sep 17 00:00:00 2001 From: Anna Malantonio Date: Thu, 14 Mar 2024 14:58:34 -0400 Subject: [PATCH 1/2] override hyrax admin_set bug --- config/initializers/spot_overrides.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/initializers/spot_overrides.rb b/config/initializers/spot_overrides.rb index 8e6637fe3..302e80a69 100644 --- a/config/initializers/spot_overrides.rb +++ b/config/initializers/spot_overrides.rb @@ -167,4 +167,21 @@ def add_sorting_to_solr(solr_parameters) solr_parameters[:sort] ||= (sort || "title_sort_si asc") end end + + # Override to fix Hyrax bug where calling Hyrax::AdminSetCreateService.find_or_create_default_admin_set + # will try to load an AdminSet's entire set of members when called. + # + # @see https://github.com/samvera/hyrax/issues/6171 + # @see https://github.com/WGBH-MLA/ams/commit/8983c933d7ffaf587ef9dbded74845eaae41ebea + module Spot + module AdminSetCreateServiceDecorator + private + + def find_default_admin_set + AdminSet.find('admin_set/default') + end + end + end + + Hyrax::AdminSetCreateService.singleton_class.send(:prepend, Spot::AdminSetCreateServiceDecorator) end From e141f71d47b3c6f4f90ade64d62abb4e7affe9e7 Mon Sep 17 00:00:00 2001 From: Anna Malantonio Date: Thu, 14 Mar 2024 15:14:04 -0400 Subject: [PATCH 2/2] add rescue clause to fix spec --- config/initializers/spot_overrides.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/spot_overrides.rb b/config/initializers/spot_overrides.rb index 302e80a69..c9479047f 100644 --- a/config/initializers/spot_overrides.rb +++ b/config/initializers/spot_overrides.rb @@ -179,6 +179,8 @@ module AdminSetCreateServiceDecorator def find_default_admin_set AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + nil end end end