Add cli tool to unsubscribe from a topic
[phinde.git] / src / phinde / Fetcher.php
index 5ea0cf24fd7b0f2d27389815756aad91bdce9372..7cf11b77ec92f1df0b8f67e38c3b78834fb00558 100644 (file)
@@ -15,12 +15,15 @@ class Fetcher
      */
     public function fetch($url, $actions, $force = false)
     {
+        $url = Helper::rewriteUrl($url);
+
         $esDoc = $this->es->get($url);
         if (isset($esDoc->status->location)
             && $esDoc->status->location != ''
         ) {
             //TODO: what if location redirects change?
             $url = $esDoc->status->location;
+            $url = Helper::rewriteUrl($url);
             $esDoc = $this->es->get($url);
         }
 
@@ -43,7 +46,7 @@ class Fetcher
         $res = $req->send();
         if ($res->getStatus() === 304) {
             //not modified since last time, so don't crawl again
-            echo "Not modified since last fetch\n";
+            Log::info("Not modified since last fetch");
             return false;
         } else if ($res->getStatus() !== 200) {
             throw new \Exception(
@@ -53,6 +56,7 @@ class Fetcher
         }
 
         $effUrl = Helper::removeAnchor($res->getEffectiveUrl());
+        $effUrl = Helper::rewriteUrl($effUrl);
         if ($effUrl != $url) {
             $this->storeRedirect($url, $effUrl);
             $url = $effUrl;
@@ -79,7 +83,7 @@ class Fetcher
 
     public function storeDoc($url, $esDoc)
     {
-        echo "Store $url\n";
+        Log::info("Store $url");
         $esDoc->status->processed = gmdate('c');
         $r = new Elasticsearch_Request(
             $GLOBALS['phinde']['elasticsearch'] . 'document/'