Bug #92230
Updated by Sybille Peters about 4 years ago
I had the scheduler task fail and abort because in one content block there was a URL such as:
<a href="mailto:http://example.org">URL causes exception</a>
This link is not correct, but I think one error should not cause link checking to abort.
This is the error message:
<pre><code class="text">
Tue, 08 Sep 2020 06:01:49 +0200 [ERROR] request="a0690b01ea8ec" component="TYPO3.CMS.Scheduler.Task.AbstractTask":
Task failed to execute successfully. Class: TYPO3\CMS\Linkvalidator\Task\ValidatorTask, UID: 36, Code: 0,
Argument 1 passed to TYPO3\CMS\Core\Utility\HttpUtility::idn_to_ascii() must be of the type string, null given,
called in /var/www/mysite/htdocs/typo3/sysext/linkvalidator/Classes/Linktype/ExternalLinktype.php on line 225 - {"exception":{},"context":true}
</code></pre>
The reason is that the 'host' is not filled on parse_url() for that URL.
For master, catching exceptions handling was completely removed in ExternalLinktype::preprossURL(). Don't know why.
For TYPO3 9, there is a catch block, but it should be catch Throwable for TYPO3 7, instead of just catch \Exception:
<pre><code class="php">
catch (\Exception $e) {
// in case of any error, return empty url.
$this->errorParams['errorType'] = 'exception';
$this->errorParams['exception'] = $e->getMessage();
$this->errorParams['message'] = $this->getErrorMessage($this->errorParams);
return '';
} catch (\Throwable $e) { // For PHP 7
// handle $e ...
return $url;
}
</code></pre>
Also, the function should handle empty $parts['hosts'] gracefully.
And if the URL can't be converted or there is some error, it is probably better to return the original URL instead of an empty string. That way we will get useful results when checking this URL.
h2. Releases
Error occurs in 9.5.20, 10.4 and master (11).