Browse Source

Convert islandora_object_load to a solr query

pull/807/head
Brandon Weigel 4 years ago
parent
commit
061ead2013
  1. 30
      includes/orphaned_objects.inc

30
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.
*

Loading…
Cancel
Save