diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/DownloadImages.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/DownloadImages.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php index 426cbe48..004bb277 100644 --- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php +++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php | |||
@@ -91,20 +91,23 @@ class DownloadImages | |||
91 | // build image path | 91 | // build image path |
92 | $absolutePath = $this->getAbsoluteLink($url, $imagePath); | 92 | $absolutePath = $this->getAbsoluteLink($url, $imagePath); |
93 | if (false === $absolutePath) { | 93 | if (false === $absolutePath) { |
94 | $this->logger->log('debug', 'Can not determine the absolute path for that image, skipping.'); | 94 | $this->logger->log('error', 'Can not determine the absolute path for that image, skipping.'); |
95 | 95 | ||
96 | return false; | 96 | return false; |
97 | } | 97 | } |
98 | 98 | ||
99 | $res = $this->client->get( | 99 | try { |
100 | $absolutePath, | 100 | $res = $this->client->get($absolutePath); |
101 | ['exceptions' => false] | 101 | } catch (\Exception $e) { |
102 | ); | 102 | $this->logger->log('error', 'Can not retrieve image, skipping.', ['exception' => $e]); |
103 | |||
104 | return false; | ||
105 | } | ||
103 | 106 | ||
104 | $ext = $this->mimeGuesser->guess($res->getHeader('content-type')); | 107 | $ext = $this->mimeGuesser->guess($res->getHeader('content-type')); |
105 | $this->logger->log('debug', 'Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]); | 108 | $this->logger->log('debug', 'Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]); |
106 | if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'])) { | 109 | if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) { |
107 | $this->logger->log('debug', 'Processed image with not allowed extension. Skipping '.$imagePath); | 110 | $this->logger->log('error', 'Processed image with not allowed extension. Skipping '.$imagePath); |
108 | 111 | ||
109 | return false; | 112 | return false; |
110 | } | 113 | } |
@@ -117,7 +120,7 @@ class DownloadImages | |||
117 | $im = false; | 120 | $im = false; |
118 | } | 121 | } |
119 | 122 | ||
120 | if ($im === false) { | 123 | if (false === $im) { |
121 | $this->logger->log('error', 'Error while regenerating image', ['path' => $localPath]); | 124 | $this->logger->log('error', 'Error while regenerating image', ['path' => $localPath]); |
122 | 125 | ||
123 | return false; | 126 | return false; |
@@ -193,6 +196,8 @@ class DownloadImages | |||
193 | return $absolute->get_uri(); | 196 | return $absolute->get_uri(); |
194 | } | 197 | } |
195 | 198 | ||
199 | $this->logger->log('error', 'Can not make an absolute link', ['base' => $base, 'url' => $url]); | ||
200 | |||
196 | return false; | 201 | return false; |
197 | } | 202 | } |
198 | } | 203 | } |