From 064b115024094220bd3603fe4729bbd5f0d90734 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 2 Nov 2020 18:52:07 +0000 Subject: [PATCH 01/12] Add Solr option for Orphaned Objects list --- includes/admin.form.inc | 10 +++ includes/orphaned_objects.inc | 147 ++++++++++++++++++++++++++-------- 2 files changed, 122 insertions(+), 35 deletions(-) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 7324f6c6..535f6c02 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -127,6 +127,16 @@ function islandora_repository_admin(array $form, array &$form_state) { ), ), ), + 'islandora_orphaned_objects_backend' => array( + '#type' => 'radios', + '#title' => t('Orphaned Objects query'), + '#description' => t('How the Orphaned Islandora Objects list is generated.'), + '#default_value' => variable_get('islandora_orphaned_objects_backend', 'Solr'), + '#options' => array( + 'Solr' => t('Solr'), + 'SPARQL' => t('SPARQL'), + ), + ), 'islandora_risearch_use_itql_when_necessary' => array( '#type' => 'checkbox', '#title' => t('Use iTQL for particular queries'), diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index f17f4185..99750353 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -54,11 +54,23 @@ function islandora_manage_orphaned_objects_form(array $form, array $form_state) or a variety of other reasons. Some of these orphans may exist intentionally. Please be cautious when deleting, as this action is irreversible.'), 'warning'); $orphaned_objects = islandora_get_orphaned_objects(); + $query_method = variable_get('islandora_orphaned_objects_backend', 'Solr'); + $rows = array(); foreach ($orphaned_objects as $orphaned_object) { - $pid = $orphaned_object['object']['value']; + if ($query_method == 'SPARQL') { + $pid = $orphaned_object['object']['value']; + } + elseif ($query_method == 'Solr') { + $pid = $orphaned_object['PID']; + } if (islandora_namespace_accessible($pid)) { - $rows[$pid] = array(l($orphaned_object['title']['value'] . " (" . $pid . ")", "islandora/object/$pid")); + if ($query_method == 'SPARQL') { + $rows[$pid] = array(l($orphaned_object['title']['value'] . " (" . $pid . ")", "islandora/object/$pid")); + } + elseif ($query_method == 'Solr') { + $rows[$pid] = array(l($orphaned_object['object_label'] . " (" . $pid . ")", "islandora/object/$pid")); + } } } ksort($rows); @@ -144,9 +156,73 @@ function islandora_manage_orphaned_objects_confirm_submit(array $form, array &$f * An array containing the results of the orphaned objects queries. */ function islandora_get_orphaned_objects() { - $connection = islandora_get_tuque_connection(); - // SPARQL: get orphaned objects, exclude any with a living parent. - $object_query = <<buildQuery($query); + $qp->solrParams['fl'] = $params; + $qp->solrLimit = 1000000000; + // Check islandora_compound_object settings and changes query filters to include compound children if necessary. + if (variable_get('islandora_compound_object_hide_child_objects_solr', TRUE)) { + $fq = variable_get('islandora_compound_object_solr_fq', '-RELS_EXT_isConstituentOf_uri_mt:[* TO *]'); + if (!empty($fq)) { + // delete islandora_compound_object_solr_fq from the list of filters + $filters = $qp->solrParams['fq']; + if (($key = array_search($fq, $filters)) !== FALSE) { + unset($filters[$key]); + $qp->solrParams['fq'] = $filters; + } + } + } + $qp->executeQuery(FALSE); + + try { + $results = $qp->islandoraSolrResult['response']['objects']; + } + catch (Exception $e) { + watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); + $results = array(); + } + + $orphaned_objects = array(); + + // Now we have $results[key]['PID'] for the pid. sparql: [key][object][value] and [key][title][value] + // Step 2: Check all results for PIDs that don't exist + + foreach ($results AS $result) { + if (array_key_exists($collection_field, $result['solr_doc'])) { + foreach ($result['solr_doc'][$collection_field] AS $collection) { + $test = islandora_object_load($collection); + if (!$test) { + $orphaned_objects[] = $result; + } + } + } + if (array_key_exists($member_field, $result['solr_doc'])) { + foreach ($result['solr_doc'][$member_field] AS $membership) { + $test = islandora_object_load($membership); + if (!$test) { + $orphaned_objects[] = $result; + } + } + } + } + $results = $orphaned_objects; + } + + elseif($query_method == "SPARQL") { + $connection = islandora_get_tuque_connection(); + // SPARQL: get orphaned objects, exclude any with a living parent. + $object_query = << !empty($optionals) ? ('OPTIONAL {{' . implode('} UNION {', $optionals) . '}}') : '', + '!filters' => !empty($filters) ? implode(' ', array_map($filter_map, $filters)) : '', + '!dead_parent_relationships' => '?p = ' . implode(' || ?p = ', $parent_relationships['predicate']), + '!live_parent_relationships' => '{' . implode(' } UNION { ', array_map($parent_map, $parent_relationships['predicate'])) . '}', + '!prefix' => implode("\n", $parent_relationships['prefix']), + )); + $results = $connection->repository->ri->sparqlQuery($sparql_query_objects); } - $filter_map = function ($filter) { - return "FILTER($filter)"; - }; - $parent_map = function ($parent) { - return "?object $parent ?liveparent"; - }; - // Use separate queries for different object types. - $sparql_query_objects = format_string($object_query, array( - '!optionals' => !empty($optionals) ? ('OPTIONAL {{' . implode('} UNION {', $optionals) . '}}') : '', - '!filters' => !empty($filters) ? implode(' ', array_map($filter_map, $filters)) : '', - '!dead_parent_relationships' => '?p = ' . implode(' || ?p = ', $parent_relationships['predicate']), - '!live_parent_relationships' => '{' . implode(' } UNION { ', array_map($parent_map, $parent_relationships['predicate'])) . '}', - '!prefix' => implode("\n", $parent_relationships['prefix']), - )); - $results = $connection->repository->ri->sparqlQuery($sparql_query_objects); return $results; } From 2f3a886bed3342d1fed5fb44369693536e715c2b Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 2 Nov 2020 19:15:05 +0000 Subject: [PATCH 02/12] Clean up comments --- includes/orphaned_objects.inc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 99750353..ffd4b0ee 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -159,7 +159,7 @@ function islandora_get_orphaned_objects() { $query_method = variable_get('islandora_orphaned_objects_backend', 'Solr'); if ($query_method == 'Solr') { - // Step 1: Solr query for the RELS_EXTs + // Solr query for all objects. $collection_field = variable_get('islandora_solr_member_of_collection_field', 'RELS_EXT_isMemberOfCollection_uri_ms'); $label_field = variable_get('islandora_solr_object_label_field', 'fgs_label_s'); $member_field = variable_get('islandora_solr_member_of_field', 'RELS_EXT_isMemberOf_uri_ms'); @@ -171,6 +171,7 @@ function islandora_get_orphaned_objects() { $qp->buildQuery($query); $qp->solrParams['fl'] = $params; $qp->solrLimit = 1000000000; + // Check islandora_compound_object settings and changes query filters to include compound children if necessary. if (variable_get('islandora_compound_object_hide_child_objects_solr', TRUE)) { $fq = variable_get('islandora_compound_object_solr_fq', '-RELS_EXT_isConstituentOf_uri_mt:[* TO *]'); @@ -195,9 +196,7 @@ function islandora_get_orphaned_objects() { $orphaned_objects = array(); - // Now we have $results[key]['PID'] for the pid. sparql: [key][object][value] and [key][title][value] - // Step 2: Check all results for PIDs that don't exist - + // Check all results for PIDs that don't exist. foreach ($results AS $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] AS $collection) { From 06163b7b2295c586df0114856e3bb40b1cb1074a Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Wed, 4 Nov 2020 15:21:46 +0000 Subject: [PATCH 03/12] Make sure each parent object is loaded only once --- includes/orphaned_objects.inc | 37 +++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index ffd4b0ee..b250fb52 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -195,26 +195,47 @@ function islandora_get_orphaned_objects() { } $orphaned_objects = array(); - + $already_checked = array(); + $dead_parents = array(); // Check all results for PIDs that don't exist. foreach ($results AS $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] AS $collection) { - $test = islandora_object_load($collection); - if (!$test) { - $orphaned_objects[] = $result; + if (in_array($collection, $dead_parents)) { + $orphaned_objects[] = $result; + } + elseif (!in_array($collection, $already_checked)) { + $test = islandora_object_load($collection); + if (!$test) { + $orphaned_objects[] = $result; + $dead_parents[] = $collection; + } + $already_checked[] = $collection; } } } if (array_key_exists($member_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$member_field] AS $membership) { - $test = islandora_object_load($membership); - if (!$test) { - $orphaned_objects[] = $result; + if (in_array($membership, $dead_parents)) { + $orphaned_objects[] = $result; + } + elseif (!in_array($membership, $already_checked)) { + $test = islandora_object_load($membership); + if (!$test) { + $orphaned_objects[] = $result; + $dead_parents[] = $membership; + } + $already_checked[] = $membership; } } } - } + } +dd("List of orphans"); +dd($orphaned_objects); +dd("List of dead parents"); +dd($dead_parents); +dd("List of checked parents"); +dd($already_checked); $results = $orphaned_objects; } From 9403d3be20e1d472b42a106e2497db6a6499dabc Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Wed, 4 Nov 2020 18:57:32 +0000 Subject: [PATCH 04/12] Style cleanup --- includes/orphaned_objects.inc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index b250fb52..ef8277b0 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -172,11 +172,11 @@ function islandora_get_orphaned_objects() { $qp->solrParams['fl'] = $params; $qp->solrLimit = 1000000000; - // Check islandora_compound_object settings and changes query filters to include compound children if necessary. + // Check islandora_compound_object filters, include compound children if necessary. if (variable_get('islandora_compound_object_hide_child_objects_solr', TRUE)) { $fq = variable_get('islandora_compound_object_solr_fq', '-RELS_EXT_isConstituentOf_uri_mt:[* TO *]'); if (!empty($fq)) { - // delete islandora_compound_object_solr_fq from the list of filters + // Delete islandora_compound_object_solr_fq from the list of filters. $filters = $qp->solrParams['fq']; if (($key = array_search($fq, $filters)) !== FALSE) { unset($filters[$key]); @@ -202,7 +202,7 @@ function islandora_get_orphaned_objects() { if (array_key_exists($collection_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$collection_field] AS $collection) { if (in_array($collection, $dead_parents)) { - $orphaned_objects[] = $result; + $orphaned_objects[] = $result; } elseif (!in_array($collection, $already_checked)) { $test = islandora_object_load($collection); @@ -217,7 +217,7 @@ function islandora_get_orphaned_objects() { if (array_key_exists($member_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$member_field] AS $membership) { if (in_array($membership, $dead_parents)) { - $orphaned_objects[] = $result; + $orphaned_objects[] = $result; } elseif (!in_array($membership, $already_checked)) { $test = islandora_object_load($membership); @@ -230,16 +230,10 @@ function islandora_get_orphaned_objects() { } } } -dd("List of orphans"); -dd($orphaned_objects); -dd("List of dead parents"); -dd($dead_parents); -dd("List of checked parents"); -dd($already_checked); - $results = $orphaned_objects; + $results = $orphaned_objects; } - elseif($query_method == "SPARQL") { + elseif ($query_method == "SPARQL") { $connection = islandora_get_tuque_connection(); // SPARQL: get orphaned objects, exclude any with a living parent. $object_query = << Date: Mon, 23 Nov 2020 15:24:21 +0000 Subject: [PATCH 05/12] Remove debug --- includes/orphaned_objects.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index ef8277b0..1766d842 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -193,7 +193,6 @@ function islandora_get_orphaned_objects() { watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); $results = array(); } - $orphaned_objects = array(); $already_checked = array(); $dead_parents = array(); From 061ead2013d0ca41b09f5d3c34b8ac3e91395a86 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 23 Nov 2020 16:29:31 +0000 Subject: [PATCH 06/12] Convert islandora_object_load to a solr query --- includes/orphaned_objects.inc | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 1766d842..530ef303 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -204,7 +204,7 @@ function islandora_get_orphaned_objects() { $orphaned_objects[] = $result; } elseif (!in_array($collection, $already_checked)) { - $test = islandora_object_load($collection); + $test = islandora_identify_dead_parents($collection); if (!$test) { $orphaned_objects[] = $result; $dead_parents[] = $collection; @@ -219,7 +219,8 @@ function islandora_get_orphaned_objects() { $orphaned_objects[] = $result; } elseif (!in_array($membership, $already_checked)) { - $test = islandora_object_load($membership); +$test=islandora_object_load($membership); + $test = islandora_identify_dead_parents($membership); if (!$test) { $orphaned_objects[] = $result; $dead_parents[] = $membership; @@ -292,6 +293,7 @@ EOQ; )); $results = $connection->repository->ri->sparqlQuery($sparql_query_objects); } +dd($results); return $results; } @@ -320,6 +322,30 @@ function islandora_delete_orphaned_objects_create_batch(array $pids) { return $batch; } +/** + * Solr query to check for deceased parents. + * + */ +function islandora_identify_dead_parents($parent) { + $parent_params = "PID"; + $parent_test = substr($parent, strpos($parent, '/') +1); + $parent_query = 'PID:"' . $parent_test . '"'; + $qp = new islandoraSolrQueryProcessor(); + $qp->buildQuery($parent_query); + $qp->solrParams['fl'] = $parent_params; + $qp->solrLimit = 1000000000; + $qp->executeQuery(FALSE); + try { + $parent_results = $qp->islandoraSolrResult['response']['objects']; + } + catch (Exception $e) { + watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); + $parent_results = array(); + } + return($parent_results); +} + + /** * Constructs and performs the deleting batch operation. * From 42775301fdad034df4b70105762146b559132552 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 23 Nov 2020 17:28:40 +0000 Subject: [PATCH 07/12] Fix the php error --- includes/orphaned_objects.inc | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 530ef303..44073886 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -55,7 +55,7 @@ function islandora_manage_orphaned_objects_form(array $form, array $form_state) Please be cautious when deleting, as this action is irreversible.'), 'warning'); $orphaned_objects = islandora_get_orphaned_objects(); $query_method = variable_get('islandora_orphaned_objects_backend', 'Solr'); - + module_load_include('inc', 'islandora', 'includes/utilities'); $rows = array(); foreach ($orphaned_objects as $orphaned_object) { if ($query_method == 'SPARQL') { @@ -219,7 +219,6 @@ function islandora_get_orphaned_objects() { $orphaned_objects[] = $result; } elseif (!in_array($membership, $already_checked)) { -$test=islandora_object_load($membership); $test = islandora_identify_dead_parents($membership); if (!$test) { $orphaned_objects[] = $result; @@ -293,7 +292,6 @@ EOQ; )); $results = $connection->repository->ri->sparqlQuery($sparql_query_objects); } -dd($results); return $results; } @@ -327,21 +325,21 @@ function islandora_delete_orphaned_objects_create_batch(array $pids) { * */ function islandora_identify_dead_parents($parent) { - $parent_params = "PID"; - $parent_test = substr($parent, strpos($parent, '/') +1); - $parent_query = 'PID:"' . $parent_test . '"'; - $qp = new islandoraSolrQueryProcessor(); - $qp->buildQuery($parent_query); - $qp->solrParams['fl'] = $parent_params; - $qp->solrLimit = 1000000000; - $qp->executeQuery(FALSE); - try { - $parent_results = $qp->islandoraSolrResult['response']['objects']; - } - catch (Exception $e) { - watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); - $parent_results = array(); - } + $parent_params = "PID"; + $parent_test = substr($parent, strpos($parent, '/') +1); + $parent_query = 'PID:"' . $parent_test . '"'; + $qp = new islandoraSolrQueryProcessor(); + $qp->buildQuery($parent_query); + $qp->solrParams['fl'] = $parent_params; + $qp->solrLimit = 1000000000; + $qp->executeQuery(FALSE); + try { + $parent_results = $qp->islandoraSolrResult['response']['objects']; + } + catch (Exception $e) { + watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); + $parent_results = array(); + } return($parent_results); } From 404221ad76f2991526b6b0f5d5787dfe5e9b712d Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Tue, 24 Nov 2020 15:01:46 +0000 Subject: [PATCH 08/12] review from bryjbrown --- includes/admin.form.inc | 2 +- includes/orphaned_objects.inc | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 535f6c02..a8598b69 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -131,7 +131,7 @@ function islandora_repository_admin(array $form, array &$form_state) { '#type' => 'radios', '#title' => t('Orphaned Objects query'), '#description' => t('How the Orphaned Islandora Objects list is generated.'), - '#default_value' => variable_get('islandora_orphaned_objects_backend', 'Solr'), + '#default_value' => variable_get('islandora_orphaned_objects_backend', 'SPARQL'), '#options' => array( 'Solr' => t('Solr'), 'SPARQL' => t('SPARQL'), diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 44073886..0a71fe1e 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -54,23 +54,20 @@ function islandora_manage_orphaned_objects_form(array $form, array $form_state) or a variety of other reasons. Some of these orphans may exist intentionally. Please be cautious when deleting, as this action is irreversible.'), 'warning'); $orphaned_objects = islandora_get_orphaned_objects(); - $query_method = variable_get('islandora_orphaned_objects_backend', 'Solr'); + $query_method = variable_get('islandora_orphaned_objects_backend', 'SPARQL'); module_load_include('inc', 'islandora', 'includes/utilities'); $rows = array(); foreach ($orphaned_objects as $orphaned_object) { if ($query_method == 'SPARQL') { $pid = $orphaned_object['object']['value']; + $title = $orphaned_object['title']['value']; } elseif ($query_method == 'Solr') { $pid = $orphaned_object['PID']; + $title = $orphaned_object['object_label']; } if (islandora_namespace_accessible($pid)) { - if ($query_method == 'SPARQL') { - $rows[$pid] = array(l($orphaned_object['title']['value'] . " (" . $pid . ")", "islandora/object/$pid")); - } - elseif ($query_method == 'Solr') { - $rows[$pid] = array(l($orphaned_object['object_label'] . " (" . $pid . ")", "islandora/object/$pid")); - } + $rows[$pid] = array(l($title . " (" . $pid . ")", "islandora/object/$pid")); } } ksort($rows); @@ -156,7 +153,7 @@ function islandora_manage_orphaned_objects_confirm_submit(array $form, array &$f * An array containing the results of the orphaned objects queries. */ function islandora_get_orphaned_objects() { - $query_method = variable_get('islandora_orphaned_objects_backend', 'Solr'); + $query_method = variable_get('islandora_orphaned_objects_backend', 'SPARQL'); if ($query_method == 'Solr') { // Solr query for all objects. @@ -195,19 +192,19 @@ function islandora_get_orphaned_objects() { } $orphaned_objects = array(); $already_checked = array(); - $dead_parents = array(); + $missing_parents = array(); // Check all results for PIDs that don't exist. 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, $dead_parents)) { + if (in_array($collection, $missing_parents)) { $orphaned_objects[] = $result; } elseif (!in_array($collection, $already_checked)) { - $test = islandora_identify_dead_parents($collection); + $test = islandora_identify_missing_parents($collection); if (!$test) { $orphaned_objects[] = $result; - $dead_parents[] = $collection; + $missing_parents[] = $collection; } $already_checked[] = $collection; } @@ -215,14 +212,14 @@ function islandora_get_orphaned_objects() { } if (array_key_exists($member_field, $result['solr_doc'])) { foreach ($result['solr_doc'][$member_field] AS $membership) { - if (in_array($membership, $dead_parents)) { + if (in_array($membership, $missing_parents)) { $orphaned_objects[] = $result; } elseif (!in_array($membership, $already_checked)) { - $test = islandora_identify_dead_parents($membership); + $test = islandora_identify_missing_parents($membership); if (!$test) { $orphaned_objects[] = $result; - $dead_parents[] = $membership; + $missing_parents[] = $membership; } $already_checked[] = $membership; } @@ -324,7 +321,7 @@ function islandora_delete_orphaned_objects_create_batch(array $pids) { * Solr query to check for deceased parents. * */ -function islandora_identify_dead_parents($parent) { +function islandora_identify_missing_parents($parent) { $parent_params = "PID"; $parent_test = substr($parent, strpos($parent, '/') +1); $parent_query = 'PID:"' . $parent_test . '"'; From 155b2bda908d8095c4ec14965acc66918fca3998 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Tue, 24 Nov 2020 15:18:07 +0000 Subject: [PATCH 09/12] Add new variable to install file --- islandora.install | 1 + 1 file changed, 1 insertion(+) diff --git a/islandora.install b/islandora.install index cc0cc49f..c08d06d6 100644 --- a/islandora.install +++ b/islandora.install @@ -59,6 +59,7 @@ function islandora_uninstall() { 'islandora_semaphore_period', 'islandora_require_obj_upload', 'islandora_breadcrumbs_backends', + 'islandora_orphaned_objects_backend', 'islandora_render_context_ingeststep', 'islandora_deny_inactive_and_deleted', ); From a7ebc54d0d899746cd112937ebb0aa1121686fbd Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Wed, 25 Nov 2020 15:10:33 +0000 Subject: [PATCH 10/12] Fix travis and failing file --- tests/datastream_validator_tests.test | 2 +- tests/scripts/travis_setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/datastream_validator_tests.test b/tests/datastream_validator_tests.test index d0176485..81d36c9b 100644 --- a/tests/datastream_validator_tests.test +++ b/tests/datastream_validator_tests.test @@ -224,7 +224,7 @@ class PrefixDatastreamValidatorTestCase extends IslandoraWebTestCase { 'dsid' => $prefix, 'path' => $this->path . $filename, 'control_group' => 'M', - ), + ), ); $object = $this->ingestConstructedObject(array(), $datastreams); return $object; diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index 5e8e4543..f798a4a3 100755 --- a/tests/scripts/travis_setup.sh +++ b/tests/scripts/travis_setup.sh @@ -42,7 +42,7 @@ if [ "$(phpenv version-name)" == "5.3.3" ]; then composer global require drupal/coder:7.* else composer global require drush/drush:7.* - composer global require drupal/coder + composer global require drupal/coder:7.* fi # Symlink the things From e2fdb9e3c20ad612aa3a6e152cacd980374bb8de Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Wed, 25 Nov 2020 16:23:16 +0000 Subject: [PATCH 11/12] Travis --- includes/admin.form.inc | 4 ++-- includes/orphaned_objects.inc | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index a8598b69..0d6ae539 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -133,8 +133,8 @@ function islandora_repository_admin(array $form, array &$form_state) { '#description' => t('How the Orphaned Islandora Objects list is generated.'), '#default_value' => variable_get('islandora_orphaned_objects_backend', 'SPARQL'), '#options' => array( - 'Solr' => t('Solr'), - 'SPARQL' => t('SPARQL'), + 'Solr' => t('Solr'), + 'SPARQL' => t('SPARQL'), ), ), 'islandora_risearch_use_itql_when_necessary' => array( diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 0a71fe1e..e911995e 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -169,7 +169,7 @@ function islandora_get_orphaned_objects() { $qp->solrParams['fl'] = $params; $qp->solrLimit = 1000000000; - // Check islandora_compound_object filters, include compound children if necessary. + // Check islandora_compound_object filters to include compound children. if (variable_get('islandora_compound_object_hide_child_objects_solr', TRUE)) { $fq = variable_get('islandora_compound_object_solr_fq', '-RELS_EXT_isConstituentOf_uri_mt:[* TO *]'); if (!empty($fq)) { @@ -319,11 +319,10 @@ function islandora_delete_orphaned_objects_create_batch(array $pids) { /** * Solr query to check for deceased parents. - * */ function islandora_identify_missing_parents($parent) { $parent_params = "PID"; - $parent_test = substr($parent, strpos($parent, '/') +1); + $parent_test = substr($parent, strpos($parent, '/') + 1); $parent_query = 'PID:"' . $parent_test . '"'; $qp = new islandoraSolrQueryProcessor(); $qp->buildQuery($parent_query); @@ -337,7 +336,7 @@ function islandora_identify_missing_parents($parent) { watchdog_exception('Islandora', $e, 'Got an exception searching for parent objects .', array(), WATCHDOG_ERROR); $parent_results = array(); } - return($parent_results); + return ($parent_results); } From dc12d524d210e5849f241876a2c3fa369d8767f8 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Wed, 25 Nov 2020 16:24:17 +0000 Subject: [PATCH 12/12] foreach fix --- includes/orphaned_objects.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index e911995e..f33de1b7 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -194,9 +194,9 @@ function islandora_get_orphaned_objects() { $already_checked = array(); $missing_parents = array(); // Check all results for PIDs that don't exist. - foreach ($results AS $result) { + foreach ($results as $result) { if (array_key_exists($collection_field, $result['solr_doc'])) { - foreach ($result['solr_doc'][$collection_field] AS $collection) { + foreach ($result['solr_doc'][$collection_field] as $collection) { if (in_array($collection, $missing_parents)) { $orphaned_objects[] = $result; } @@ -211,7 +211,7 @@ function islandora_get_orphaned_objects() { } } if (array_key_exists($member_field, $result['solr_doc'])) { - foreach ($result['solr_doc'][$member_field] AS $membership) { + foreach ($result['solr_doc'][$member_field] as $membership) { if (in_array($membership, $missing_parents)) { $orphaned_objects[] = $result; }