From 845c33964a534c32c248d0276c0623139ebe0e90 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Tue, 26 Jun 2012 11:19:24 -0300 Subject: [PATCH] updated purge_datastream to iterate backwards through the rels elements instead of forward so it can correctly remove all of them --- api/fedora_item.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index d4c8aff0..a41529aa 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -347,7 +347,9 @@ RDF; $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { - foreach ($rels as $rel) { + for ($i = $rels->length; $i>0; $i--) { + $rel = $rels->item($i-1); +// foreach ($rels as $rel) { if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. empty($object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||