changeset 2639:2d9955974316

Possible catch on rogue findNodeByAttribute
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 19 Jan 2017 13:10:59 +0000
parents 82b6b75a91bc
children 3a0cd11bf232
files php/save.php
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/php/save.php	Thu Jan 19 13:09:03 2017 +0000
+++ b/php/save.php	Thu Jan 19 13:10:59 2017 +0000
@@ -110,14 +110,16 @@
     }
     foreach($n1 as $page) {
         $ref = $page->getAttribute("ref");
-        $pn2 = findNodeByAttribute($n2, "ref", $ref);
-        if ($pn2 != 0 && $pn2.getAttribute("state") != "complete") {
-            $saved_root->removeChild($pn2);
-            $pn2 = 0;
-        }
-        if ($pn2 == 0) {
-            $pn1 = $doc->importNode($page->item(0), true);
-            $docRoot->appendChild($pn1);
+        if (!empty($ref)) {
+            $pn2 = findNodeByAttribute($n2, "ref", $ref);
+            if ($pn2 != 0 && $pn2.getAttribute("state") != "complete") {
+                $saved_root->removeChild($pn2);
+                $pn2 = 0;
+            }
+            if ($pn2 == 0) {
+                $pn1 = $doc->importNode($page->item(0), true);
+                $docRoot->appendChild($pn1);
+            }
         }
     }
 }