From 0f522bed38a1ec676921d573ac56488966e5bc86 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Wed, 16 Oct 2024 14:19:05 -0400 Subject: [PATCH] Remove reliance on noid for find (#6924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove reliance on noid for find Switches from using noids to using a fallback... look first by id, and then by alternate_identifier instead. I created a work in dassie with VALKYRIE_TRANSITION=true and then I was unable to edit the work because I don’t have an alternative identifier. * Rearrange code to allow fallback to alternative_id --- lib/hyrax/valkyrie_can_can_adapter.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/hyrax/valkyrie_can_can_adapter.rb b/lib/hyrax/valkyrie_can_can_adapter.rb index 70a4786f4f..471106bd11 100644 --- a/lib/hyrax/valkyrie_can_can_adapter.rb +++ b/lib/hyrax/valkyrie_can_can_adapter.rb @@ -19,10 +19,17 @@ def self.for_class?(member_class) # # @raise Hyrax::ObjectNotFoundError def self.find(_model_class, id) - return Hyrax.query_service.find_by(id: id) unless Hyrax.config.enable_noids? + self.find_by(id:) || Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id) rescue Valkyrie::Persistence::ObjectNotFoundError => err raise Hyrax::ObjectNotFoundError, err.message end + + private + + def self.find_by(id:) + Hyrax.query_service.find_by(id:) + rescue Valkyrie::Persistence::ObjectNotFoundError + end end end