Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class LinkTargetResponse

protected string $urlChecker = '';


/**
* @var array<int,array{from:string, to:string}>
*/
Expand Down
15 changes: 11 additions & 4 deletions Classes/Controller/BrokenLinkListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@
// sort by error type
'error' => [
['check_status', 'ASC'],
['link_type', 'ASC'],
['url_response', 'ASC']
['error_type', 'ASC'],
['errno', 'ASC']
],
'error_reverse' => [
['link_type', 'DESC'],
['url_response', 'DESC']
['check_status', 'DESC'],
['error_type', 'DESC'],
['errno', 'DESC']
],
];

Expand Down Expand Up @@ -1104,6 +1105,12 @@
}
$variables['linktext'] = $hookObj->getBrokenLinkText($row, $linkTargetResponse->getCustom());

// error
if ($row['error_type'] ?? false && $row['errno'] ?? false) {

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Expression on left side of ?? is not nullable.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Left side of && is always false.

Check failure on line 1109 in Classes/Controller/BrokenLinkListController.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Expression on left side of ?? is not nullable.
$variables['error'] = $row['error_type'] . ':' . $row['errno'];
}


// last check of record
// show the oldest last_check, either for the record or for the link target
$variables['lastcheck_combined'] = StringUtil::formatTimestampAsString($row['last_check'] < $row['last_check_url'] ? $row['last_check'] : $row['last_check_url']);
Expand Down
50 changes: 50 additions & 0 deletions Classes/Controller/Filter/BrokenLinkListFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

protected const KEY_HOWTOTRAVERSE = 'howtotraverse';

protected const KEY_ERROR = 'error';

/** @var string */
protected const LINK_TYPE_FILTER_DEFAULT = 'all';

Expand Down Expand Up @@ -61,6 +63,8 @@
/** @var string */
protected $urlFilterMatch = self::URL_MATCH_DEFAULT;

protected string $errorFilter = '';

protected int $checkStatusFilter = self::CHECK_STATUS_DEFAULT;

protected bool $usePagetreeCache = true;
Expand All @@ -78,6 +82,7 @@
string $linkType = self::LINK_TYPE_DEFAULT,
string $url = '',
string $urlMatch = self::URL_MATCH_DEFAULT,
string $errorFilter = '',
int $checkStatus = self::CHECK_STATUS_DEFAULT,
bool $usePagetreeCache = true,
string $howtotraverse = self::HOW_TO_TRAVERSE_DEFAULT
Expand All @@ -86,6 +91,7 @@
$this->linktype_filter = $linkType;
$this->url_filtre = $url;
$this->urlFilterMatch = $urlMatch;
$this->errorFilter = $errorFilter;
$this->checkStatusFilter = $checkStatus;
$extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
$this->usePagetreeCache = $usePagetreeCache;
Expand All @@ -99,6 +105,7 @@
$moduleData->get('linktype_searchFilter', 'all'),
$moduleData->get('url_searchFilter', ''),
$moduleData->get('url_match_searchFilter', 'partial'),
$moduleData->get('error_searchFilter', ''),
(int)$moduleData->get('check_status', (string)self::CHECK_STATUS_DEFAULT),
(bool)$moduleData->get('useCache', 1),
$moduleData->get('howtotraverse', self::HOW_TO_TRAVERSE_DEFAULT),
Expand All @@ -112,6 +119,7 @@
$values[self::KEY_LINKTYPE] ?? self::LINK_TYPE_DEFAULT,
$values[self::KEY_URL] ?? '',
$values[self::KEY_URL_MATCH] ?? self::URL_MATCH_DEFAULT,
$values[self::KEY_ERROR] ?? '',
$values[self::KEY_CHECK_STATUS] ?? self::CHECK_STATUS_DEFAULT,
$values[self::KEY_USE_CACHE] ?? 1,
$values[self::KEY_HOWTOTRAVERSE] ?? self::HOW_TO_TRAVERSE_DEFAULT,
Expand All @@ -125,6 +133,7 @@
self::KEY_LINKTYPE => $this->getLinktypeFilter(),
self::KEY_URL => $this->getUrlFilter(),
self::KEY_URL_MATCH => $this->getUrlFilterMatch(),
self::KEY_ERROR => $this->getErrorFilter(),
self::KEY_CHECK_STATUS => $this->getCheckStatusFilter(),
self::KEY_USE_CACHE => $this->isUsePagetreeCache(),
self::KEY_HOWTOTRAVERSE => $this->getHowtotraverse(),
Expand Down Expand Up @@ -204,6 +213,47 @@
$this->urlFilterMatch = $urlFilterMatch;
}

/**
* Combined eror of <errorType>:<errno> or several e.g. 'libcurlErrno:6|custom:11'
*/
public function getErrorFilter(): string
{
return $this->errorFilter;
}

/**
* @deprecated because errorFilter can contain several, e.g. ''
*/
public function getErrorTypeFilter(): string
{
$errorFilter = $this->errorFilter;
if (!$errorFilter) {
return '';
}
$parts = explode(':', $errorFilter);
return $parts[0] ?? '';
}

/**
* @deprecated because errorFilter can contain several, e.g. ''
*/

public function getErrnoFilter(): int
{
$errorFilter = $this->errorFilter;
if (!$errorFilter) {
return '';

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.4, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-latest (8.2, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.4, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.

Check failure on line 245 in Classes/Controller/Filter/BrokenLinkListFilter.php

View workflow job for this annotation

GitHub Actions / all core-v12 (8.1, composerInstallMax)

Method Sypets\Brofix\Controller\Filter\BrokenLinkListFilter::getErrnoFilter() should return int but returns string.
}
$parts = explode(':', $errorFilter);
return (int)($parts[1] ?? 0);
}


public function setErrorFilter(string $errorFilter): void
{
$this->errorFilter = $errorFilter;
}

public function getCheckStatusFilter(): int
{
return $this->checkStatusFilter;
Expand Down
6 changes: 6 additions & 0 deletions Classes/LinkAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public function recheckUrl(string &$message, array $record, ServerRequestInterfa
$brokenLinkRecord['last_check_url'] = \time();
$brokenLinkRecord['last_check'] = \time();
$brokenLinkRecord['url_checker'] = $linkTargetResponse->getUrlChecker();
$brokenLinkRecord['error_type'] = $linkTargetResponse->getErrorType();
$brokenLinkRecord['errno'] = $linkTargetResponse->getErrno();
$identifier = [
'url' => $url,
'link_type' => $linkType
Expand Down Expand Up @@ -557,6 +559,8 @@ protected function checkLinks(array $links, array $linkTypes, int $mode = 0): vo
$record['last_check_url'] = $linkTargetResponse->getLastChecked() ?: \time();
$record['last_check'] = \time();
$record['url_checker'] = $linkTargetResponse->getUrlChecker();
$brokenLinkRecord['error_type'] = $linkTargetResponse->getErrorType();
$brokenLinkRecord['errno'] = $linkTargetResponse->getErrno();
if ($this->brokenLinkRepository->insertOrUpdateBrokenLink($record)
&& $linkTargetResponse->isError()
) {
Expand All @@ -570,6 +574,8 @@ protected function checkLinks(array $links, array $linkTypes, int $mode = 0): vo
$record['last_check_url'] = $linkTargetResponse->getLastChecked() ?: \time();
$record['last_check'] = \time();
$record['url_checker'] = $linkTargetResponse->getUrlChecker();
$brokenLinkRecord['error_type'] = $linkTargetResponse->getErrorType();
$brokenLinkRecord['errno'] = $linkTargetResponse->getErrno();
$this->brokenLinkRepository->insertOrUpdateBrokenLink($record);
}
}
Expand Down
35 changes: 35 additions & 0 deletions Classes/Repository/BrokenLinkRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,41 @@ public function getBrokenLinks(
$queryBuilder->expr()->eq(self::TABLE . '.record_uid', $queryBuilder->createNamedParameter($filter->getUidFilter(), Connection::PARAM_INT))
);
}

// errorFilter, might be 'custom:13' or 'custom:13|httpErrorCode:404' etc. Several combinations, separated
// by '|', each combination with <errortype>:<errno>

$errorFilter = $filter->getErrorFilter();
$errorConstraintsOr = [];
if ($errorFilter !== '') {
$errorCombinations = explode('|', $errorFilter);
foreach($errorCombinations as $errorCombination) {

$parts = explode(':', $errorCombination);
if (count($parts) === 2) {

$errorType = $parts[0];
$errno = (int)$parts[1];
$errorConstraintsOr[] = $queryBuilder->expr()->and(
$queryBuilder->expr()->eq(self::TABLE . '.error_type',
$queryBuilder->createNamedParameter($errorType)),
$queryBuilder->expr()->eq(self::TABLE . '.errno',
$queryBuilder->createNamedParameter($errno, Connection::PARAM_INT))
);
} else if (count($parts) === 1) {
$errorType = $parts[0];
$errorConstraintsOr[] = $queryBuilder->expr()->eq(self::TABLE . '.error_type',
$queryBuilder->createNamedParameter($errorType));

}
}
}
if ($errorConstraintsOr) {
$queryBuilder->andWhere(
$queryBuilder->expr()->or(...$errorConstraintsOr)
);
}

$urlFilter = $filter->getUrlFilter();
if ($urlFilter != '') {
switch ($filter->getUrlFilterMatch()) {
Expand Down
1 change: 1 addition & 0 deletions Configuration/Backend/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'linktype_searchFilter' => 'all',
'url_searchFilter' => 'all',
'url_match_searchFilter' => 'partial',
'error_searchFilter' => '',
'check_status' => '1',
'current_record_uid' => '',
'current_record_table' => '',
Expand Down
20 changes: 19 additions & 1 deletion Resources/Private/Partials/BrokenLinkList.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,25 @@
<f:if condition="{item.status} === 2"><core:icon identifier="actions-check-circle"/></f:if>
<f:if condition="{item.status} === 3"><core:icon identifier="actions-question-circle"/></f:if>
<f:if condition="{item.status} === 4"><core:icon identifier="actions-ban"/></f:if>
{item.linkmessage -> f:format.raw()}</td>
{item.linkmessage -> f:format.raw()}
<f:if condition="{item.status} == 1">
<div class="inline-action">
<f:if condition="{filter.errorFilter}">
<f:then>
<a class="btn btn-default" href="{listUri}&error_searchFilter=" title="{f:translate(key: 'LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.filter.unset.tooltip', extensionName: 'Brofix')}">
<core:icon identifier="actions-close" size="medium"/>
</a>
</f:then>
<f:else>
<a class="btn btn-default" href="{listUri}&error_searchFilter={item.error}" title="{f:translate(key: 'LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.filter.element.uid.tooltip', extensionName: 'Brofix')}">
<core:icon identifier="actions-filter" size="small"/>
<f:translate key="filter" extensionName="Brofix">Filter</f:translate>
</a>
</f:else>
</f:if>
</div>
</f:if>
</td>

<f:comment>==== last_check_url ====</f:comment>
<td class="mobile-optional" title="">
Expand Down
11 changes: 11 additions & 0 deletions Resources/Private/Partials/BrokenLinksForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@
</select>
</div>

<f:comment>Error code</f:comment>
<div class="col">
<label for="error_searchFilter">
<f:translate extensionName="Brofix" key="LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.tableHead.error"/>:
</label>
<input type="search" size="20" class="form-control t3js-clearable hasDefaultValue slug-impact t3js-charcounter-initialized"
name="error_searchFilter"
placeholder=""
id="error_searchFilter"
value="{filter.errorFilter}"/>
</div>

<f:if condition="{configuration.showalllinks}">
<div class="col">
Expand Down
4 changes: 4 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ CREATE TABLE tx_brofix_broken_links (
url_response text,
check_status int(5) DEFAULT '4' NOT NULL,
url_checker varchar(100) DEFAULT '' NOT NULL,
error_type varchar(50) DEFAULT '' NOT NULL,
errno int(11) unsigned DEFAULT '0' NOT NULL,

last_check int(11) DEFAULT '0' NOT NULL,
last_check_url int(11) DEFAULT '0' NOT NULL,
Expand All @@ -40,6 +42,8 @@ CREATE TABLE tx_brofix_link_target_cache (
check_status int(11) unsigned DEFAULT '0' NOT NULL,
url_response text,
url_checker varchar(100) DEFAULT '' NOT NULL,
error_type varchar(50) DEFAULT '' NOT NULL,
errno int(11) unsigned DEFAULT '0' NOT NULL,

PRIMARY KEY (uid)
);
Expand Down
Loading