Issue Bug Closed

#99863PHP 8.1 issues with linkvalidator

Ralph Brugger 02/07/23, 09:33 updated 07/09/24, 12:46

Description

We have two issues within the likvalidator when checking https://www.emas.de
`GET https://www.emas.de` resulted in a `403 Forbidden` response:

1. issue

PHP Warning: Undefined array key “exception” in
typo3_src-11.5.21/typo3/sysext/linkvalidator/Classes/Linktype/ExternalLinktype.php
line 316

public function getErrorMessage($errorParams)
default:
    $message = sprintf($lang->getLL('list.report.otherhttpcode'), $errorType, $errorParams['exception']);

could / should bei changed into:

$errorHint = '';
if(isset($errorParams['message'])){
     $errorHint = $errorParams['message'];
}
$message = sprintf($lang->getLL('list.report.otherhttpcode'), $errorType, $errorHint);

2. issue

PHP Warning: Trying to access array offset on value of type bool in
typo3_src-11.5.21/typo3/sysext/linkvalidator/Classes/Report/LinkValidatorReport.php line 578

protected function renderTableRow($table, array $row)
$response = $row['url_response'];
if ($response['valid']) {
    $linkMessage = '<span class="text-success">' . htmlspecialchars($languageService->getLL('list.msg.ok')) . '</span>';
} else {
    $linkMessage = '<span class="text-danger">'
        . nl2br(
            // Encode for output
            htmlspecialchars(
                $hookObj->getErrorMessage($response['errorParams']),
                ENT_QUOTES,
                'UTF-8',
                false
            )
        )
        . '</span>';
}
if ($response && $response['valid']) {
    $linkMessage = '<span class="text-success">' . htmlspecialchars($languageService->getLL('list.msg.ok')) . '</span>';
} elseif($response && isset($response['errorParams'])) {
    $linkMessage = '<span class="text-danger">'
        . nl2br(
            // Encode for output
            htmlspecialchars(
                $hookObj->getErrorMessage($response['errorParams']),
                ENT_QUOTES,
                'UTF-8',
                false
            )
        )
        . '</span>';
}else{
      $linkMessage = '<span class="text-danger">Invalid response</span>';
}

Reviews 2