# HG changeset patch # User Nicholas Jillings # Date 1484831459 0 # Node ID 2d9955974316f399fb5de25f3ea156af64c3b6a1 # Parent 82b6b75a91bc85118b8a68ec7a9b21db7469b808 Possible catch on rogue findNodeByAttribute diff -r 82b6b75a91bc -r 2d9955974316 php/save.php --- 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); + } } } }