[BUGFIX] linkvalidator: Fatal error: Call to a member function getUrl() 33/33333/3
authorPhilipp Gampe <philipp.gampe@typo3.org>
Thu, 16 Oct 2014 10:25:26 +0000 (12:25 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Mon, 15 Dec 2014 10:19:00 +0000 (11:19 +0100)
The external link checker tries to provide detailed information in case
an URL is not accessible. To do this, it analyses the strack trace
provided by the exception.

Replace the stracktrace parsing with a more reliable method by checking
the last event. In case of a loop, the last event contains the response
object in the 'data' key.

Resolves: #62266
Releases: master,6.2
Change-Id: I51aaf3d6af85877541e920afaee76e6cac368e7b
Reviewed-on: http://review.typo3.org/33333
Reviewed-by: Jesper Paardekooper <jesper.paardekooper@gmail.com>
Tested-by: Jesper Paardekooper <jesper.paardekooper@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/linkvalidator/Classes/Linktype/ExternalLinktype.php

index 44fc3b3..f488074 100644 (file)
@@ -86,10 +86,14 @@ class ExternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                        $isValidUrl = FALSE;
                        // A redirect loop occurred
                        if ($e->getCode() === 40) {
-                               // Parse the exception for more information
-                               $trace = $e->getTrace();
-                               $traceUrl = $trace[0]['args'][0]->getUrl()->getUrl();
-                               $traceCode = $trace[0]['args'][1]->getStatus();
+                               $traceUrl = $request->getUrl()->getURL();
+                               /** @var \HTTP_Request2_Response $event['data'] */
+                               $event = $request->getLastEvent();
+                               if ($event['data'] instanceof \HTTP_Request2_Response) {
+                                       $traceCode = $event['data']->getStatus();
+                               } else {
+                                       $traceCode = 'loop';
+                               }
                                $errorParams['errorType'] = 'loop';
                                $errorParams['location'] = $traceUrl;
                                $errorParams['errorCode'] = $traceCode;