aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper
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
parent7f55941856549a3f5f45c42fdc171d66ff7ee297 (diff)
downloadwallabag-48656e0eaac006a80f21e9aec8900747fe76283a.tar.gz
wallabag-48656e0eaac006a80f21e9aec8900747fe76283a.tar.zst
wallabag-48656e0eaac006a80f21e9aec8900747fe76283a.zip
Fixing tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php3
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php21
2 files changed, 14 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index d90d3dc8..1986ab33 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -65,6 +65,7 @@ class ContentProxy
65 65
66 $entry->setUrl($content['url'] ?: $url); 66 $entry->setUrl($content['url'] ?: $url);
67 $entry->setTitle($title); 67 $entry->setTitle($title);
68 $entry->setContent($html);
68 69
69 $entry->setLanguage($content['language']); 70 $entry->setLanguage($content['language']);
70 $entry->setMimetype($content['content_type']); 71 $entry->setMimetype($content['content_type']);
@@ -75,8 +76,6 @@ class ContentProxy
75 $entry->setDomainName($domainName); 76 $entry->setDomainName($domainName);
76 } 77 }
77 78
78 $entry->setContent($html);
79
80 if (isset($content['open_graph']['og_image'])) { 79 if (isset($content['open_graph']['og_image'])) {
81 $entry->setPreviewPicture($content['open_graph']['og_image']); 80 $entry->setPreviewPicture($content['open_graph']['og_image']);
82 } 81 }
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}