From 9e734d6726e8c757c762d30f50002bd2ef0e8034 Mon Sep 17 00:00:00 2001 From: Kylea Jackson Date: Mon, 9 Mar 2015 12:57:58 -0300 Subject: [PATCH] Added recursive derivative check --- includes/delete_datastream.form.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/delete_datastream.form.inc b/includes/delete_datastream.form.inc index b7715657..ce1959df 100644 --- a/includes/delete_datastream.form.inc +++ b/includes/delete_datastream.form.inc @@ -53,7 +53,14 @@ function islandora_datastream_to_purge(AbstractObject $object, $dsid) { $dsid_map = function ($hook_definition) { return $hook_definition['destination_dsid']; }; - $dsids = array_map($dsid_map, $hooks); + $dsids = array(); + $derived_dsids = array_map($dsid_map, $hooks); + while ($current = array_pop($derived_dsids)) { + $dsids[] = $current; + $current_derived = islandora_datastream_to_purge($object, $current); + $current_diff = array_diff($current_derived, $derived_dsids, $dsids); + $derived_dsids = array_merge($derived_dsids, $current_diff); + } return $dsids; }