Issue Bug Closed

#85067Uncaught Exception in Linkvalidator at 'Too many redirects' link

Loek Hilgersom 05/23/18, 13:56 updated 11/10/19, 09:10

Description

An uncaugt exception occurs when Linkvalidator encounters an external link which doesn’t redirect properly (the page is stuck in a redirect loop, browser says ‘The page isn’t redirecting properly’).

Also, if the exception would be solved, this type of link would not be reported as a broken link!

The exception is thrown because $e->getResponse() returns NULL, therefor getStatusCode() can not be called.

I made a workaround by replacing the lines starting at line 88 in ExternalLinktype->checkLink with this:

        } catch (TooManyRedirectsException $e) {
            $isValidUrl = false;
            $lastRequest = $e->getRequest();
            $response = $e->getResponse();
            $errorParams['errorType'] = 'loop';
            $errorParams['location'] = (string)$lastRequest->getUri();
            if ($response === null) {
                $errorParams['errorCode'] = '301';
            } else {
                $errorParams['errorCode'] = $response->getStatusCode();
            }

Reviews 2