From 64334d20665deca57ad2d522c517c844aec281d0 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 30 Nov 2020 16:29:16 +0000 Subject: [PATCH 1/4] Exclude configured root from orphans list --- includes/orphaned_objects.inc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index f33de1b7..6dc3a0ab 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -154,7 +154,8 @@ function islandora_manage_orphaned_objects_confirm_submit(array $form, array &$f */ function islandora_get_orphaned_objects() { $query_method = variable_get('islandora_orphaned_objects_backend', 'SPARQL'); - + $root_pid = variable_get('islandora_repository_pid', 'islandora:root'); + $root_pid = "info:fedora/" . $root_pid; if ($query_method == 'Solr') { // Solr query for all objects. $collection_field = variable_get('islandora_solr_member_of_collection_field', 'RELS_EXT_isMemberOfCollection_uri_ms'); @@ -197,16 +198,18 @@ function islandora_get_orphaned_objects() { foreach ($results as $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] as $collection) { - if (in_array($collection, $missing_parents)) { - $orphaned_objects[] = $result; - } - elseif (!in_array($collection, $already_checked)) { - $test = islandora_identify_missing_parents($collection); - if (!$test) { + if ($collection != $root_pid) { + if (in_array($collection, $missing_parents)) { $orphaned_objects[] = $result; - $missing_parents[] = $collection; } - $already_checked[] = $collection; + elseif (!in_array($collection, $already_checked)) { + $test = islandora_identify_missing_parents($collection); + if (!$test) { + $orphaned_objects[] = $result; + $missing_parents[] = $collection; + } + $already_checked[] = $collection; + } } } } From f36f2da8c6f25787486ad7ea331f36585c0a33a1 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 30 Nov 2020 16:54:49 +0000 Subject: [PATCH 2/4] Exclude root collection from orphans list --- includes/orphaned_objects.inc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 6dc3a0ab..02cf5255 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -155,7 +155,7 @@ function islandora_manage_orphaned_objects_confirm_submit(array $form, array &$f function islandora_get_orphaned_objects() { $query_method = variable_get('islandora_orphaned_objects_backend', 'SPARQL'); $root_pid = variable_get('islandora_repository_pid', 'islandora:root'); - $root_pid = "info:fedora/" . $root_pid; + $root_pid_check = "info:fedora/" . $root_pid; if ($query_method == 'Solr') { // Solr query for all objects. $collection_field = variable_get('islandora_solr_member_of_collection_field', 'RELS_EXT_isMemberOfCollection_uri_ms'); @@ -198,17 +198,19 @@ function islandora_get_orphaned_objects() { foreach ($results as $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] as $collection) { - if ($collection != $root_pid) { - if (in_array($collection, $missing_parents)) { - $orphaned_objects[] = $result; - } - elseif (!in_array($collection, $already_checked)) { - $test = islandora_identify_missing_parents($collection); - if (!$test) { + if($result['PID'] != $root_pid) { + if ($collection != $root_pid_check) { + if (in_array($collection, $missing_parents)) { + $orphaned_objects[] = $result; + } + elseif (!in_array($collection, $already_checked)) { + $test = islandora_identify_missing_parents($collection); + if (!$test) { $orphaned_objects[] = $result; $missing_parents[] = $collection; + } + $already_checked[] = $collection; } - $already_checked[] = $collection; } } } From cb1e47e88d54d16d5ca79efc7f1f11136c5208dc Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Tue, 1 Dec 2020 14:34:19 +0000 Subject: [PATCH 3/4] More efficient IFs --- includes/orphaned_objects.inc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 02cf5255..b7f8258c 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -198,19 +198,17 @@ function islandora_get_orphaned_objects() { foreach ($results as $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] as $collection) { - if($result['PID'] != $root_pid) { - if ($collection != $root_pid_check) { - if (in_array($collection, $missing_parents)) { + if (($result['PID'] != $root_pid) && ($collection != $root_pid_check) ) { + if (in_array($collection, $missing_parents)) { + $orphaned_objects[] = $result; + } + elseif (!in_array($collection, $already_checked)) { + $test = islandora_identify_missing_parents($collection); + if (!$test) { $orphaned_objects[] = $result; + $missing_parents[] = $collection; } - elseif (!in_array($collection, $already_checked)) { - $test = islandora_identify_missing_parents($collection); - if (!$test) { - $orphaned_objects[] = $result; - $missing_parents[] = $collection; - } - $already_checked[] = $collection; - } + $already_checked[] = $collection; } } } From 4258cfa4159e557a98f4c6371202606817594e13 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Tue, 1 Dec 2020 15:51:15 +0000 Subject: [PATCH 4/4] Travis --- includes/orphaned_objects.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index b7f8258c..30b44c7f 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -198,7 +198,7 @@ function islandora_get_orphaned_objects() { foreach ($results as $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] as $collection) { - if (($result['PID'] != $root_pid) && ($collection != $root_pid_check) ) { + if (($result['PID'] != $root_pid) && ($collection != $root_pid_check)) { if (in_array($collection, $missing_parents)) { $orphaned_objects[] = $result; }