aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/DownloadImages.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-30 11:27:09 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-30 11:27:09 +0100
commit48656e0eaac006a80f21e9aec8900747fe76283a (patch)
tree8b685bd1b2b68b47a12b2bc17f076683c466603f /src/Wallabag/CoreBundle/Helper/DownloadImages.php
parent7f55941856549a3f5f45c42fdc171d66ff7ee297 (diff)
downloadwallabag-48656e0eaac006a80f21e9aec8900747fe76283a.tar.gz
wallabag-48656e0eaac006a80f21e9aec8900747fe76283a.tar.zst
wallabag-48656e0eaac006a80f21e9aec8900747fe76283a.zip
Fixing tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/DownloadImages.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php21
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}