Fixes bug in dom recursion for cached pages in search controller, a=chris

Chris Pollett [2012-04-28 18:Apr:th]
Fixes bug in dom recursion for cached pages in search controller, a=chris
Filename
controllers/search_controller.php
diff --git a/controllers/search_controller.php b/controllers/search_controller.php
index 63a934ba8..e2fa7acd7 100755
--- a/controllers/search_controller.php
+++ b/controllers/search_controller.php
@@ -656,7 +656,7 @@ class SearchController extends Controller implements CrawlConstants
                     $href = $clone->getAttribute("href");
                     $href = UrlParser::canonicalLink($href, $url, false);
                     $clone->setAttribute("href", $href);
-                    return $clone;
+                    $node->replaceChild($clone, $node->childNodes->item($k));
                 }
             } else if (in_array($tag_name, array("img", "object",
                 "script"))) {
@@ -664,12 +664,12 @@ class SearchController extends Controller implements CrawlConstants
                     $src = $clone->getAttribute("src");
                     $src = UrlParser::canonicalLink($src, $url, false);
                     $clone->setAttribute("src", $src);
-                    return $clone;
+                    $node->replaceChild($clone, $node->childNodes->item($k));
                 }
             } else {
-                if($clone->nodeType == XML_ELEMENT_NODE) {
+                if($tag_name != -1) {
                     $clone = $this->canonicalizeLinks($clone, $url);
-                    if($clone != null) {
+                    if(is_object($clone)) {
                         $node->replaceChild($clone, $node->childNodes->item($k));
                     }
                 }
ViewGit