From 530d5a3aca407b1e30308824dd3b7f142925390c Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Tue, 26 Jun 2012 12:01:00 -0300 Subject: [PATCH] added notes to reverse iterator in purge_relationships --- api/fedora_item.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index a41529aa..7fdd211c 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -347,9 +347,10 @@ RDF; $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { + // iterate backwards so if we delete something our pointer doesn't get out of sync for ($i = $rels->length; $i>0; $i--) { $rel = $rels->item($i-1); -// foreach ($rels as $rel) { +// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted 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) ||