‪TYPO3CMS  ‪main
TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype Class Reference
Inheritance diagram for TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype:
TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface

Public Member Functions

 __construct (protected readonly RequestFactory $requestFactory,)
 
 setAdditionalConfig (array $config)
 
bool checkLink (string $origUrl, array $softRefEntry, LinkAnalyzer $reference)
 
string getErrorMessage (array $errorParams)
 
string fetchType (array $value, string $type, string $key)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype
 getIdentifier ()
 
array getErrorParams ()
 
string getBrokenUrl (array $row)
 

Protected Member Functions

 requestUrl (string $url, string $method, array $options)
 
 preprocessUrl (string $url)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype
 setErrorParams ($value)
 
 getLanguageService ()
 

Protected Attributes

const ERROR_TYPE_HTTP_STATUS_CODE = 'httpStatusCode'
 
const ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO = 'libcurlErrno'
 
const ERROR_TYPE_GENERIC_EXCEPTION = 'exception'
 
const ERROR_TYPE_UNKNOWN = 'unknown'
 
array $urlReports = array( )
 
array $urlErrorParams = array( )
 
array $headers
 
string $method = 'HEAD'
 
string $range = '0-4048'
 
int $timeout = 0
 
string $identifier = 'external'
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype
array $errorParams = []
 
string $identifier = ''
 

Detailed Description

This class provides external links checking !!! There are some known issues with external link checking:

  • ‪"false positives": Link targets considered broken which are not broken
  • ‪no rate limiting when checking links on external sites (e.g. crawl delay)
  • ‪no caching of results (except for a runtime cache during link checking which will be invalid on next run) see "Known Problems" in the linkvalidator documentation

Definition at line 39 of file ExternalLinktype.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::__construct ( protected readonly RequestFactory  $requestFactory)

Definition at line 94 of file ExternalLinktype.php.

Member Function Documentation

◆ checkLink()

bool TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::checkLink ( string  $origUrl,
array  $softRefEntry,
LinkAnalyzer  $reference 
)

Checks a given URL for validity

Parameters
string$origUrl‪The URL to check
array$softRefEntry‪The soft reference entry which builds the context of that URL
\TYPO3\CMS\Linkvalidator\LinkAnalyzer$reference‪Parent instance
Returns
‪bool TRUE on success or FALSE on error
Exceptions

Implements TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface.

Definition at line 142 of file ExternalLinktype.php.

References TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\$errorParams, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\$headers, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\$range, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\$timeout, TYPO3\CMS\Webhooks\Message\$url, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\preprocessUrl(), TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\requestUrl(), and TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\setErrorParams().

◆ fetchType()

string TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::fetchType ( array  $value,
string  $type,
string  $key 
)

Get the external type from the softRefParserObj result

Parameters
array$value‪Reference properties
string$type‪Current type
string$key‪Validator hook name
Returns
‪string Fetched type

Reimplemented from TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype.

Definition at line 336 of file ExternalLinktype.php.

◆ getErrorMessage()

string TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::getErrorMessage ( array  $errorParams)

Generate the localized error message from the error params saved from the parsing

Parameters
array$errorParams‪All parameters needed for the rendering of the error message
Returns
‪string Validation error message

Implements TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface.

Definition at line 244 of file ExternalLinktype.php.

References TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\$errorParams, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\ERROR_TYPE_HTTP_STATUS_CODE, TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO, and TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\getLanguageService().

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\requestUrl().

◆ preprocessUrl()

TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::preprocessUrl ( string  $url)
protected

Convert domain to punycode to handle domains with non-ASCII characters

Definition at line 348 of file ExternalLinktype.php.

References TYPO3\CMS\Webhooks\Message\$url, and TYPO3\CMS\Core\Utility\HttpUtility\buildUrl().

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\checkLink().

◆ requestUrl()

◆ setAdditionalConfig()

TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::setAdditionalConfig ( array  $config)

Function to override config of Linktype. Should be used only if necessary. Add additional configuration to TSconfig.

Reimplemented from TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype.

Definition at line 98 of file ExternalLinktype.php.

References $GLOBALS.

Member Data Documentation

◆ $headers

array TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$headers
protected
Initial value:
= array(
'User-Agent' => 'TYPO3 linkvalidator',
'Accept' => '*/*',
'Accept-Language' => '*',
'Accept-Encoding' => '*',
)

List of HTTP request headers to use for checking a URL

Definition at line 64 of file ExternalLinktype.php.

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\checkLink().

◆ $identifier

string TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$identifier = 'external'
protected

Definition at line 92 of file ExternalLinktype.php.

◆ $method

string TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$method = 'HEAD'
protected

Preferred method of fetching (HEAD | GET). If HEAD is used, we fallback to GET

Definition at line 76 of file ExternalLinktype.php.

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\requestUrl().

◆ $range

string TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$range = '0-4048'
protected

For GET method, set number of bytes returned.

This limits the payload, but may fail for some sites.

Definition at line 84 of file ExternalLinktype.php.

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\checkLink().

◆ $timeout

int TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$timeout = 0
protected

Total timeout of the request in seconds. Using 0 (which is usually the default) may cause the request to take indefinitely, which means the scheduler task never ends.

Definition at line 90 of file ExternalLinktype.php.

Referenced by TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype\checkLink().

◆ $urlErrorParams

array TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$urlErrorParams = array( )
protected

Cached list of all error parameters of the URLs, which were already checked for the current processing

Definition at line 58 of file ExternalLinktype.php.

◆ $urlReports

array TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::$urlReports = array( )
protected

Cached list of the URLs, which were already checked for the current processing

Definition at line 52 of file ExternalLinktype.php.

◆ ERROR_TYPE_GENERIC_EXCEPTION

const TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::ERROR_TYPE_GENERIC_EXCEPTION = 'exception'
protected

◆ ERROR_TYPE_HTTP_STATUS_CODE

const TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::ERROR_TYPE_HTTP_STATUS_CODE = 'httpStatusCode'
protected

◆ ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO

const TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO = 'libcurlErrno'
protected

◆ ERROR_TYPE_UNKNOWN

const TYPO3\CMS\Linkvalidator\Linktype\ExternalLinktype::ERROR_TYPE_UNKNOWN = 'unknown'
protected