Browse Source

added notes to reverse iterator in purge_relationships

pull/140/head
Jason MacWilliams 13 years ago
parent
commit
530d5a3aca
  1. 3
      api/fedora_item.inc

3
api/fedora_item.inc

@ -347,9 +347,10 @@ RDF;
$modified = FALSE; $modified = FALSE;
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { 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--) { for ($i = $rels->length; $i>0; $i--) {
$rel = $rels->item($i-1); $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. 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) || empty($object) ||
(($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||

Loading…
Cancel
Save