[BUGFIX] Check $http_response_headers in GeneralUtility::getUrl() 42/40142/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 10 Jun 2015 07:19:07 +0000 (09:19 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 10 Jun 2015 14:14:51 +0000 (16:14 +0200)
If one queries a local, non-existing file with GeneralUtility::getUrl()
AND sets the $report parameter, implode() fails because
$http_response_headers remains NULL, as there is no HTTP request.
Check the existance of $http_response_headers and alternatively use the
URL for logging.

Resolves: #67383
Releases: master, 6.2
Change-Id: I796935fbef090061c7d12502593190f4223765b3
Reviewed-on: http://review.typo3.org/40142
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 8c1a1e9..4c52e35 100755 (executable)
@@ -2489,7 +2489,7 @@ Connection: close
                        $content = @file_get_contents($url, FALSE, $ctx);
                        if ($content === FALSE && isset($report)) {
                                $report['error'] = -1;
-                               $report['message'] = 'Couldn\'t get URL: ' . implode(LF, $http_response_header);
+                               $report['message'] = 'Couldn\'t get URL: ' . (isset($http_response_header) ? implode(LF, $http_response_header) : $url);
                        }
                } else {
                        if (isset($report)) {
@@ -2498,7 +2498,7 @@ Connection: close
                        $content = @file_get_contents($url);
                        if ($content === FALSE && isset($report)) {
                                $report['error'] = -1;
-                               $report['message'] = 'Couldn\'t get URL: ' . implode(LF, $http_response_header);
+                               $report['message'] = 'Couldn\'t get URL: ' . (isset($http_response_header) ? implode(LF, $http_response_header) : $url);
                        }
                }
                return $content;