Browse Source

Make sure each parent object is loaded only once

pull/807/head
Brandon Weigel 4 years ago
parent
commit
06163b7b22
  1. 23
      includes/orphaned_objects.inc

23
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) {
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) {
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;
}

Loading…
Cancel
Save