mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 04:16:10 +01:00
Properly handle guzzle exception for fetching images
This commit is contained in:
parent
fcbda4c093
commit
6570ec5ca9
2 changed files with 42 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Wrm\Events\Service;
|
namespace Wrm\Events\Service;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||||
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
||||||
use TYPO3\CMS\Core\DataHandling\SlugHelper;
|
use TYPO3\CMS\Core\DataHandling\SlugHelper;
|
||||||
|
@ -177,7 +178,7 @@ class DestinationDataImportService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$data = $this->dataFetcher->fetchSearchResult($import);
|
$data = $this->dataFetcher->fetchSearchResult($import);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->error('Could not receive data.');
|
$this->logger->error('Could not receive data.');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +540,13 @@ class DestinationDataImportService
|
||||||
$file = new \SplFileInfo($fileUrl);
|
$file = new \SplFileInfo($fileUrl);
|
||||||
$temporaryFilename = GeneralUtility::tempnam($file->getBasename());
|
$temporaryFilename = GeneralUtility::tempnam($file->getBasename());
|
||||||
|
|
||||||
$response = $this->dataFetcher->fetchImage($fileUrl);
|
try {
|
||||||
|
$response = $this->dataFetcher->fetchImage($fileUrl);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->logger->error('Cannot load file ' . $fileUrl);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$fileContent = $response->getBody()->__toString();
|
$fileContent = $response->getBody()->__toString();
|
||||||
if ($response->getStatusCode() !== 200) {
|
if ($response->getStatusCode() !== 200) {
|
||||||
$this->logger->error('Cannot load file ' . $fileUrl);
|
$this->logger->error('Cannot load file ' . $fileUrl);
|
||||||
|
|
33
Documentation/Changelog/3.0.1.rst
Normal file
33
Documentation/Changelog/3.0.1.rst
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
3.0.1
|
||||||
|
=====
|
||||||
|
|
||||||
|
Breaking
|
||||||
|
--------
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Fixes
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Do not break import on missing image
|
||||||
|
|
||||||
|
Guzzle might throw exceptions instead of returning the response.
|
||||||
|
We extend our import to also watch out for exceptions and handle them the same way
|
||||||
|
as a response other than 200.
|
||||||
|
|
||||||
|
Relates: #10253
|
||||||
|
|
||||||
|
Tasks
|
||||||
|
-----
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Deprecation
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Nothing
|
Loading…
Reference in a new issue