]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/DownloadImages.php
Fixing tests
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / DownloadImages.php
index 426cbe4812702d1f98eea306e83838b536b12155..004bb277515b1a436a761526a687c886b5f04082 100644 (file)
@@ -91,20 +91,23 @@ class DownloadImages
         // build image path
         $absolutePath = $this->getAbsoluteLink($url, $imagePath);
         if (false === $absolutePath) {
-            $this->logger->log('debug', 'Can not determine the absolute path for that image, skipping.');
+            $this->logger->log('error', 'Can not determine the absolute path for that image, skipping.');
 
             return false;
         }
 
-        $res = $this->client->get(
-            $absolutePath,
-            ['exceptions' => false]
-        );
+        try {
+            $res = $this->client->get($absolutePath);
+        } catch (\Exception $e) {
+            $this->logger->log('error', 'Can not retrieve image, skipping.', ['exception' => $e]);
+
+            return false;
+        }
 
         $ext = $this->mimeGuesser->guess($res->getHeader('content-type'));
         $this->logger->log('debug', 'Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]);
-        if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'])) {
-            $this->logger->log('debug', 'Processed image with not allowed extension. Skipping '.$imagePath);
+        if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
+            $this->logger->log('error', 'Processed image with not allowed extension. Skipping '.$imagePath);
 
             return false;
         }
@@ -117,7 +120,7 @@ class DownloadImages
             $im = false;
         }
 
-        if ($im === false) {
+        if (false === $im) {
             $this->logger->log('error', 'Error while regenerating image', ['path' => $localPath]);
 
             return false;
@@ -193,6 +196,8 @@ class DownloadImages
             return $absolute->get_uri();
         }
 
+        $this->logger->log('error', 'Can not make an absolute link', ['base' => $base, 'url' => $url]);
+
         return false;
     }
 }