[BUGFIX] Catch RequestException in GeneralUtility::getUrl() 79/47779/7
authorChristoph Kratz <ckr@rtp.ch>
Tue, 19 Apr 2016 10:51:01 +0000 (12:51 +0200)
committerNicole Cordes <typo3@cordes.co>
Wed, 20 Apr 2016 09:27:32 +0000 (11:27 +0200)
When a request in getUrl() fails (e.g. due to exceeded time limit, host
misconfiguration) Guzzle throws an exception.

This patch restores the behaviour of getUrl() before using Guzzle by
catching the exception.

Resolves: #75757
Releases: master
Change-Id: Iedc36cce48eaee85beeb7c448b546dc3a49034d0
Reviewed-on: https://review.typo3.org/47779
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 02bf724..6a2eca3 100755 (executable)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use GuzzleHttp\Exception\RequestException;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
@@ -2025,7 +2026,19 @@ class GeneralUtility
                 $configuration = [];
             }
 
-            $response = $requestFactory->request($url, 'GET', $configuration);
+            try {
+                if (isset($report)) {
+                    $report['lib'] = 'GuzzleHttp';
+                }
+                $response = $requestFactory->request($url, 'GET', $configuration);
+            } catch (RequestException $exception) {
+                if (isset($report)) {
+                    $report['error'] = $exception->getHandlerContext()['errno'];
+                    $report['message'] = $exception->getMessage();
+                }
+                return false;
+            }
+
             $content = '';
 
             // Add the headers to the output