From 4435b72380300b34227bf9a8ca7f1639251a5800 Mon Sep 17 00:00:00 2001 From: Sybille Peters Date: Wed, 2 Mar 2022 19:49:49 +0100 Subject: [PATCH] [WIP] Filter by error type todo - use a select list instead of an edit field - show the error code only for admin users Resolves: #163 --- .../LinkTargetPersistentCache.php | 16 ++ .../Controller/BrokenLinkListController.php | 18 +- .../Filter/BrokenLinkListFilter.php | 41 +++- Classes/LinkAnalyzer.php | 11 + Classes/Linktype/AbstractLinktype.php | 5 + Classes/Linktype/ExternalLinktype.php | 39 ++- Classes/Linktype/FileLinktype.php | 25 +- Classes/Linktype/LinktypeInterface.php | 2 + Classes/Repository/BrokenLinkRepository.php | 10 + Classes/Updates/ErrorCodeUpdateWizard.php | 225 ++++++++++++++++++ .../Private/Language/Module/locallang.xlf | 3 + .../Templates/Backend/BrokenLinkList.html | 27 ++- Resources/Public/JavaScript/Brofix.js | 1 + .../LinkTargetPersistentCacheTest.php | 2 +- .../Repository/BrokenLinkRepositoryTest.php | 14 ++ ext_localconf.php | 4 + ext_tables.sql | 2 + 17 files changed, 429 insertions(+), 16 deletions(-) create mode 100644 Classes/Updates/ErrorCodeUpdateWizard.php diff --git a/Classes/CheckLinks/LinkTargetCache/LinkTargetPersistentCache.php b/Classes/CheckLinks/LinkTargetCache/LinkTargetPersistentCache.php index 8f9af4223..323126621 100644 --- a/Classes/CheckLinks/LinkTargetCache/LinkTargetPersistentCache.php +++ b/Classes/CheckLinks/LinkTargetCache/LinkTargetPersistentCache.php @@ -121,6 +121,13 @@ public function setResult(string $linkTarget, string $linkType, array $urlRespon */ protected function insert(string $linkTarget, string $linkType, array $urlResponse, int $checkStatus): void { + $errorCode = ''; + $errorType = $urlResponse['errorParams']['errorType'] ?? ''; + $errno = (int)($urlResponse['errorParams']['errno'] ?? 0); + if ($errorType) { + $errorCode = $errorType . '_' . $errno; + } + $queryBuilder = $this->generateQueryBuilder(); $queryBuilder ->insert(static::TABLE) @@ -129,6 +136,7 @@ protected function insert(string $linkTarget, string $linkType, array $urlRespon 'url' => $linkTarget, 'link_type' => $linkType, 'url_response' => \json_encode($urlResponse), + 'error_code' => $errorCode, 'check_status' => $checkStatus, 'last_check' => \time() ] @@ -144,6 +152,13 @@ protected function insert(string $linkTarget, string $linkType, array $urlRespon */ protected function update(string $linkTarget, string $linkType, array $urlResponse, int $checkStatus): void { + $errorCode = ''; + $errorType = $urlResponse['errorParams']['errorType'] ?? ''; + $errno = (int)($urlResponse['errorParams']['errno'] ?? 0); + if ($errorType) { + $errorCode = $errorType . '_' . $errno; + } + $queryBuilder = $this->generateQueryBuilder(); $queryBuilder ->update(static::TABLE) @@ -152,6 +167,7 @@ protected function update(string $linkTarget, string $linkType, array $urlRespon $queryBuilder->expr()->eq('link_type', $queryBuilder->createNamedParameter($linkType)) ) ->set('url_response', \json_encode($urlResponse)) + ->set('error_code', $errorCode) ->set('check_status', (string)$checkStatus) ->set('last_check', (string)\time()) ->executeStatement(); diff --git a/Classes/Controller/BrokenLinkListController.php b/Classes/Controller/BrokenLinkListController.php index 600231da9..a3724e0a3 100644 --- a/Classes/Controller/BrokenLinkListController.php +++ b/Classes/Controller/BrokenLinkListController.php @@ -311,11 +311,18 @@ protected function getSettingsFromQueryParameters(): void if ($linkType !== null) { $this->filter->setLinktypeFilter($linkType ?: 'all'); } + $errorCodeFilter = GeneralUtility::_GP('errorcode_searchFilter'); + if ($errorCodeFilter !== null) { + $this->filter->setErrorcodeFilter($errorCodeFilter); + } $this->userSettings = UserSettings::initializeFromSettingsAndGetParameters($this->pObj->MOD_SETTINGS); // to prevent deleting session, when user sort the records - if (!is_null(GeneralUtility::_GP('url_searchFilter')) || !is_null(GeneralUtility::_GP('title_searchFilter')) || !is_null(GeneralUtility::_GP('uid_searchFilter'))) { + if (!is_null(GeneralUtility::_GP('url_searchFilter')) + || !is_null(GeneralUtility::_GP('title_searchFilter')) + || !is_null(GeneralUtility::_GP('uid_searchFilter')) + || !is_null(GeneralUtility::_GP('errorcode_searchFilter'))) { $this->backendSession->store(BackendSession::FILTER_KEY_LINKLIST, $this->filter); } @@ -595,7 +602,9 @@ protected function initializeViewForBrokenLinks(): void $this->view->assign('linktype_filter', $filter->getLinktypeFilter()); $this->view->assign('url_filter', $filter->getUrlFilter()); $this->view->assign('url_match_searchFilter', $filter->getUrlFilterMatch()); + $this->view->assign('errorcode_filter', $filter->getErrorcodeFilter()); $this->view->assign('view_mode', $this->userSettings->getViewMode()); + if ($this->id === 0) { $this->createFlashMessagesForRootPage(); } elseif (empty($items)) { @@ -887,11 +896,13 @@ protected function renderTableRow($table, array $row): array $variables['pagetitle'] = $path[0] ?? ''; // error message - $response = $response = json_decode($row['url_response'], true); + $response = \json_decode($row['url_response'], true); $errorParams = new ErrorParams($response['errorParams']); + $errorCode = ''; if ($response['valid']) { $linkMessage = '' . htmlspecialchars($languageService->getLL('list.msg.ok')) . ''; } else { + $errorCode = $hookObj->getErrorShortcut($errorParams); $linkMessage = sprintf( '%s', nl2br( @@ -905,7 +916,7 @@ protected function renderTableRow($table, array $row): array nl2br( // Encode for output htmlspecialchars( - $hookObj->getErrorMessage($errorParams), + $hookObj->getErrorMessage($errorParams) . ' [' . $errorCode . ']', ENT_QUOTES, 'UTF-8', false @@ -914,6 +925,7 @@ protected function renderTableRow($table, array $row): array ); } $variables['linkmessage'] = $linkMessage; + $variables['error_code'] = $errorCode; // link / URL $variables['linktarget'] = $hookObj->getBrokenUrl($row); diff --git a/Classes/Controller/Filter/BrokenLinkListFilter.php b/Classes/Controller/Filter/BrokenLinkListFilter.php index 30ec5b5e5..072378025 100644 --- a/Classes/Controller/Filter/BrokenLinkListFilter.php +++ b/Classes/Controller/Filter/BrokenLinkListFilter.php @@ -6,17 +6,29 @@ use Sypets\Brofix\Util\Arrayable; +/** + * Stores current filter settings for filtering in broken link list. + * + * If a new item is added, it must be added to constructor, + * getInstanceFromArray and toArray() + */ class BrokenLinkListFilter implements Arrayable { /** @var string */ protected const KEY_UID = 'uid'; + /** @var string */ protected const KEY_URL = 'url'; + /** @var string */ protected const KEY_LINKTYPE = 'linktype'; + /** @var string */ protected const KEY_URL_MATCH = 'urlMatch'; + /** @var string */ + protected const KEY_ERRORCODE_MATCH = 'errorCode'; + /** @var string */ protected const LINK_TYPE_FILTER_DEFAULT = 'all'; @@ -43,6 +55,11 @@ class BrokenLinkListFilter implements Arrayable /** @var string */ protected $urlFilterMatch = self::URL_MATCH_DEFAULT; + /** + * @var string + */ + protected $errorcodeFilter = ''; + /** * @var string * @deprecated @@ -53,12 +70,14 @@ public function __construct( string $uid = '', string $linkType = self::LINK_TYPE_DEFAULT, string $url = '', - string $urlMatch = self::URL_MATCH_DEFAULT + string $urlMatch = self::URL_MATCH_DEFAULT, + string $errorCode = '' ) { $this->uid_filtre = $uid; $this->linktype_filter = $linkType; $this->url_filtre = $url; $this->urlFilterMatch = $urlMatch; + $this->errorcodeFilter = $errorCode; } public static function getInstanceFromArray(array $values): BrokenLinkListFilter @@ -67,7 +86,8 @@ public static function getInstanceFromArray(array $values): BrokenLinkListFilter $values[self::KEY_UID] ?? '', $values[self::KEY_LINKTYPE] ?? self::LINK_TYPE_DEFAULT, $values[self::KEY_URL] ?? '', - $values[self::KEY_URL_MATCH] ?? self::URL_MATCH_DEFAULT + $values[self::KEY_URL_MATCH] ?? self::URL_MATCH_DEFAULT, + $values[self::KEY_ERRORCODE_MATCH] ?? '' ); } @@ -78,6 +98,7 @@ public function toArray(): array self::KEY_LINKTYPE => $this->getLinktypeFilter(), self::KEY_URL => $this->getUrlFilter(), self::KEY_URL_MATCH => $this->getUrlFilterMatch(), + self::KEY_ERRORCODE_MATCH => $this->getErrorcodeFilter(), ]; } @@ -146,6 +167,22 @@ public function setUrlFilterMatch(string $urlFilterMatch): void $this->urlFilterMatch = $urlFilterMatch; } + /** + * @return string + */ + public function getErrorcodeFilter(): string + { + return $this->errorcodeFilter; + } + + /** + * @param string $errorcodeFilter + */ + public function setErrorcodeFilter(string $errorcodeFilter): void + { + $this->errorcodeFilter = $errorcodeFilter; + } + /** @deprecated */ public function getTitleFilter(): string { diff --git a/Classes/LinkAnalyzer.php b/Classes/LinkAnalyzer.php index ac31df31d..d89aac1da 100644 --- a/Classes/LinkAnalyzer.php +++ b/Classes/LinkAnalyzer.php @@ -399,7 +399,17 @@ protected function checkLinks(array $links, array $linkTypes, int $mode = 0): vo 'valid' => false, 'errorParams' => $hookObj->getErrorParams()->toArray() ]; + // @todo create class for url_response $record['url_response'] = json_encode($response) ?: ''; + + $errorCode = ''; + $errorType = $response['errorParams']['errorType'] ?? ''; + $errno = (int)($response['errorParams']['errno'] ?? 0); + if ($errorType) { + $errorCode = $errorType . '_' . $errno; + } + + $record['error_code'] = $errorCode; // last_check reflects time of last check (may be older if URL was in cache) $record['last_check_url'] = $hookObj->getLastChecked() ?: \time(); $record['last_check'] = \time(); @@ -408,6 +418,7 @@ protected function checkLinks(array $links, array $linkTypes, int $mode = 0): vo } elseif (GeneralUtility::_GP('showalllinks')) { $response = ['valid' => true]; $record['url_response'] = json_encode($response) ?: ''; + $record['error_code'] = ''; $record['last_check_url'] = $hookObj->getLastChecked() ?: \time(); $record['last_check'] = \time(); $this->brokenLinkRepository->insertOrUpdateBrokenLink($record); diff --git a/Classes/Linktype/AbstractLinktype.php b/Classes/Linktype/AbstractLinktype.php index 650d22e67..d840cc2b5 100644 --- a/Classes/Linktype/AbstractLinktype.php +++ b/Classes/Linktype/AbstractLinktype.php @@ -89,6 +89,11 @@ public function getErrorParams(): ErrorParams return $this->errorParams; } + public function getErrorShortcut(ErrorParams $errorParams = null): string + { + return $errorParams->getErrorType() . '_' . $errorParams->getErrno(); + } + /** * Base type fetching method, based on the type that softRefParserObj returns * diff --git a/Classes/Linktype/ExternalLinktype.php b/Classes/Linktype/ExternalLinktype.php index 215413455..9f97e590b 100644 --- a/Classes/Linktype/ExternalLinktype.php +++ b/Classes/Linktype/ExternalLinktype.php @@ -40,10 +40,23 @@ class ExternalLinktype extends AbstractLinktype implements LoggerAwareInterface { use LoggerAwareTrait; - // HTTP status code was delivered (and can be found in $errorParams->errno) - public const ERROR_TYPE_HTTP_STATUS_CODE = 'httpStatusCode'; - // An error occurred in lowlevel handler and a cURL error code can be found in $errorParams->errno - public const ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO = 'libcurlErrno'; + /** + * @var string + * @todo to be deprecated, use self::ERROR_TYPE_HTTP_STATUS_CODE + */ + public const ERROR_TYPE_HTTP_STATUS_CODE_DEPRECATED = 'httpStatusCode'; + + /** @var string */ + public const ERROR_TYPE_HTTP_STATUS_CODE = 'http'; + + /** + * @var string + * @todo to be deprecated, use self::ERROR_TYPE_CURL + */ + public const ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO_DEPRECATED = 'libcurlErrno'; + + /** @var string */ + public const ERROR_TYPE_CURL = 'curl'; public const ERROR_TYPE_TOO_MANY_REDIRECTS = 'tooManyRedirects'; public const ERROR_TYPE_UNABLE_TO_PARSE = 'unableToParseUri'; public const ERROR_TYPE_UNKNOWN = 'unknown'; @@ -285,7 +298,7 @@ protected function requestUrl(string $url, string $method, array $options): bool 'cURL error', strlen('cURL error') ) === 0)) { - $this->errorParams->setErrorType(self::ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO); + $this->errorParams->setErrorType(self::ERROR_TYPE_CURL); $this->errorParams->setErrno((int)($handlerContext['errno'])); // use shorter error message if (isset($handlerContext['error'])) { @@ -320,6 +333,18 @@ public function getLastChecked(): int return $this->lastChecked; } + public function getErrorShortcut(ErrorParams $errorParams = null): string + { + $type = $errorParams->getErrorType(); + if ($type === self::ERROR_TYPE_HTTP_STATUS_CODE_DEPRECATED) { + $type = self::ERROR_TYPE_HTTP_STATUS_CODE; + } elseif ($type === self::ERROR_TYPE_CURL) { + $type = self::ERROR_TYPE_CURL; + } + + return $type . '_' . $errorParams->getErrno(); + } + /** * Generate the localized error message from the error params saved from the parsing * @@ -339,6 +364,7 @@ public function getErrorMessage(ErrorParams $errorParams = null): string switch ($errorType) { case self::ERROR_TYPE_HTTP_STATUS_CODE: + case self::ERROR_TYPE_HTTP_STATUS_CODE_DEPRECATED: $message = $lang->getLL('list.report.error.httpstatus.' . $errno); if (!$message) { if ($errno !== 0) { @@ -350,7 +376,8 @@ public function getErrorMessage(ErrorParams $errorParams = null): string } break; - case self::ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO: + case self::ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO_DEPRECATED: + case self::ERROR_TYPE_CURL: $message = ''; if ($errno > 0) { // get localized error message diff --git a/Classes/Linktype/FileLinktype.php b/Classes/Linktype/FileLinktype.php index 1cb3be9b1..c44fec4be 100644 --- a/Classes/Linktype/FileLinktype.php +++ b/Classes/Linktype/FileLinktype.php @@ -26,6 +26,17 @@ */ class FileLinktype extends AbstractLinktype { + /** + * @var string + */ + protected const ERROR_TYPE_FILE = 'file'; + + /** + * @var int + */ + protected const ERROR_ERRNO_FILE_MISSING = 1; + + public function __construct() { $this->initializeErrorParams(); @@ -69,13 +80,21 @@ public function checkLink(string $url, array $softRefEntry, int $flags = 0): boo $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); try { $file = $resourceFactory->retrieveFileOrFolderObject($url); + $isMissing = (bool)(($file !== null) ? $file->isMissing() : true); } catch (FileDoesNotExistException $e) { - return false; + $isMissing = true; } catch (FolderDoesNotExistException $e) { - return false; + $isMissing = true; + } + + if ($isMissing === false) { + return true; } - return (bool)(($file !== null) ? !$file->isMissing() : false); + // file is missing + $this->errorParams->setErrorType(self::ERROR_TYPE_FILE); + $this->errorParams->setErrno(self::ERROR_ERRNO_FILE_MISSING); + return false; } /** diff --git a/Classes/Linktype/LinktypeInterface.php b/Classes/Linktype/LinktypeInterface.php index ced3e62ca..1c7afac35 100644 --- a/Classes/Linktype/LinktypeInterface.php +++ b/Classes/Linktype/LinktypeInterface.php @@ -58,6 +58,8 @@ public function initializeErrorParams(array $params = null): void; */ public function getErrorParams(): ErrorParams; + public function getErrorShortcut(ErrorParams $errorParams = null): string; + /** * Generate the localized error message from the error params saved from the parsing * diff --git a/Classes/Repository/BrokenLinkRepository.php b/Classes/Repository/BrokenLinkRepository.php index 679acf43f..6001a3aab 100644 --- a/Classes/Repository/BrokenLinkRepository.php +++ b/Classes/Repository/BrokenLinkRepository.php @@ -153,6 +153,16 @@ public function getBrokenLinks(array $pageList, array $linkTypes, array $searchF ); } + $errorcode = $filter->getErrorcodeFilter(); + if ($errorcode) { + $queryBuilder->andWhere( + $queryBuilder->expr()->eq( + self::TABLE . '.error_code', + $queryBuilder->createNamedParameter($errorcode) + ) + ); + } + if ($orderBy !== []) { $values = array_shift($orderBy); if ($values && is_array($values) && count($values) === 2) { diff --git a/Classes/Updates/ErrorCodeUpdateWizard.php b/Classes/Updates/ErrorCodeUpdateWizard.php new file mode 100644 index 000000000..ad57b928b --- /dev/null +++ b/Classes/Updates/ErrorCodeUpdateWizard.php @@ -0,0 +1,225 @@ + 'http', + 'libcurlErrno' => 'curl', + 'libcurlError' => 'curl', + ]; + + protected const TABLES = [ + 'tx_brofix_broken_links', + 'tx_brofix_link_target_cache', + ]; + + /** + * Return the identifier for this wizard + * This should be the same string as used in the ext_localconf class registration + * + * @return string + */ + public function getIdentifier(): string + { + return 'brofix_errorCodeUpdateWizard'; + } + + /** + * Return the speaking name of this wizard + * + * @return string + */ + public function getTitle(): string + { + return 'Convert broken link records in database (adds error_code field)'; + } + + /** + * Return the description for this wizard + * + * @return string + */ + public function getDescription(): string + { + return ''; + } + + protected function urlResponseToErrorCode(array $response): string + { + $errorType = $response['errorParams']['errorType'] ?? ''; + $errorCode = (int)($response['errorParams']['errno'] ?? 0); + if (!$errorType) { + return ''; + } + foreach (self::ERROR_TYPE_MAPPING as $key => $value) { + if ($errorType === $key) { + $errorType = $value; + } + } + return $errorType . '_' . $errorCode; + } + + protected function updateRecord(string $table, $row): int + { + $urlResponseString = $row['url_response'] ?? ''; + if (!$urlResponseString) { + return 0; + } + $response = \json_decode($urlResponseString, true); + if (!$response) { + return 0; + } + $errorCode = $this->urlResponseToErrorCode($response); + if (!$errorCode) { + return 0; + } + $row['error_code'] = $errorCode; + return (int)GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionForTable($table) + ->update($table, $row, ['uid' => $row['uid']]); + } + + /** + * Execute the update + * + * Called when a wizard reports that an update is necessary + * + * @return bool + */ + public function executeUpdate(): bool + { + $table = 'tx_brofix_broken_links'; + /** + * @var ConnectionPool $connectionPool + */ + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable($table); + + // check if any record exists with field error_code empty + $stmt = $queryBuilder + ->select('uid', 'url_response', 'error_code') + ->from($table) + ->where( + $queryBuilder->expr()->eq( + $table . '.error_code', + $queryBuilder->createNamedParameter('') + ) + ) + ->executeQuery(); + while ($row = $stmt->fetchAssociative()) { + $this->updateRecord($table, $row); + } + + $table = 'tx_brofix_link_target_cache'; + $queryBuilder = $connectionPool->getQueryBuilderForTable($table); + $stmt = $queryBuilder + ->select('uid', 'url_response', 'error_code') + ->from($table) + ->where( + $queryBuilder->expr()->and( + $queryBuilder->expr()->eq( + $table . '.error_code', + $queryBuilder->createNamedParameter('') + ), + $queryBuilder->expr()->eq( + $table . '.check_status', + $queryBuilder->createNamedParameter(2, \PDO::PARAM_INT) + ) + ) + ) + ->executeQuery(); + while ($row = $stmt->fetchAssociative()) { + $this->updateRecord($table, $row); + } + return true; + } + + /** + * Is an update necessary? + * + * Is used to determine whether a wizard needs to be run. + * Check if data for migration exists. + * + * This returns true if at least record with empty error_code exists in list of broken links + * + * @return bool Whether an update is required (TRUE) or not (FALSE) + */ + public function updateNecessary(): bool + { + $table = 'tx_brofix_broken_links'; + /** + * @var ConnectionPool $connectionPool + */ + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable($table); + + // check if any record exists with field error_code empty + $count = (int)$queryBuilder + ->count('uid') + ->from($table) + ->where( + $queryBuilder->expr()->eq( + $table . '.error_code', + $queryBuilder->createNamedParameter('') + ) + ) + ->executeQuery() + ->fetchOne(); + if ($count > 0) { + return true; + } + + $table = 'tx_brofix_link_target_cache'; + $queryBuilder = $connectionPool->getQueryBuilderForTable($table); + $count = (int)$queryBuilder + ->count('uid') + ->from($table) + ->where( + $queryBuilder->expr()->and( + $queryBuilder->expr()->eq( + $table . '.error_code', + $queryBuilder->createNamedParameter('') + ), + $queryBuilder->expr()->eq( + $table . '.check_status', + $queryBuilder->createNamedParameter(2, \PDO::PARAM_INT) + ) + ) + ) + ->executeQuery() + ->fetchOne(); + if ($count > 0) { + return true; + } + + return false; + } + + /** + * Returns an array of class names of prerequisite classes + * + * This way a wizard can define dependencies like "database up-to-date" or + * "reference index updated" + * + * @return string[] + */ + public function getPrerequisites(): array + { + // we need to make sure the new DB column was already added. + return [ + DatabaseUpdatedPrerequisite::class, + ]; + } +} diff --git a/Resources/Private/Language/Module/locallang.xlf b/Resources/Private/Language/Module/locallang.xlf index fda8603e9..7808388d7 100644 --- a/Resources/Private/Language/Module/locallang.xlf +++ b/Resources/Private/Language/Module/locallang.xlf @@ -81,6 +81,9 @@ no exact match + + Error code + Title diff --git a/Resources/Private/Templates/Backend/BrokenLinkList.html b/Resources/Private/Templates/Backend/BrokenLinkList.html index 5b3604708..b0dc9c0a4 100644 --- a/Resources/Private/Templates/Backend/BrokenLinkList.html +++ b/Resources/Private/Templates/Backend/BrokenLinkList.html @@ -95,6 +95,16 @@ + +
+ +
+ + +
+

@@ -226,7 +236,22 @@ - {item.linkmessage -> f:format.raw()} + {item.linkmessage -> f:format.raw()} +
+ + + + + + + + + Filter + + + +
+ {item.lastcheck} diff --git a/Resources/Public/JavaScript/Brofix.js b/Resources/Public/JavaScript/Brofix.js index 465d6ed28..365283585 100644 --- a/Resources/Public/JavaScript/Brofix.js +++ b/Resources/Public/JavaScript/Brofix.js @@ -40,6 +40,7 @@ define(['jquery'], function($) { $('#uid_searchFilter').attr('value', ''); $('#linktype_searchFilter').val('all'); $('#url_searchFilter').attr('value', ''); + $('#errorcode_searchFilter').attr('value', ''); $('#url_match_searchFilter').val('partial'); $('#refreshLinkList').click(); }); diff --git a/Tests/Functional/CheckLinks/LinkTargetCache/LinkTargetPersistentCacheTest.php b/Tests/Functional/CheckLinks/LinkTargetCache/LinkTargetPersistentCacheTest.php index b793b0330..e6555382d 100644 --- a/Tests/Functional/CheckLinks/LinkTargetCache/LinkTargetPersistentCacheTest.php +++ b/Tests/Functional/CheckLinks/LinkTargetCache/LinkTargetPersistentCacheTest.php @@ -141,7 +141,7 @@ public function setEntrySetsCorrectValueToLastSet(): void 'valid' => false, 'errorParams' => [ 'isValid' => false, - 'errorType' => 'httpStatusCode', + 'errorType' => 'http', 'errno' => 404, 'exceptionMsg' => '', 'message' => '404 - Page not found', diff --git a/Tests/Functional/Repository/BrokenLinkRepositoryTest.php b/Tests/Functional/Repository/BrokenLinkRepositoryTest.php index e9bb80136..90b5f9b2a 100644 --- a/Tests/Functional/Repository/BrokenLinkRepositoryTest.php +++ b/Tests/Functional/Repository/BrokenLinkRepositoryTest.php @@ -390,6 +390,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7', ], [ 'record_uid' => 2, @@ -402,6 +403,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7', ], [ 'record_uid' => 3, @@ -414,6 +416,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => '85', 'link_type' => 'db', 'element_type' => 'textmedia', + 'error_code' => 'page_4' ], [ 'record_uid' => 5, @@ -426,6 +429,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'file:88', 'link_type' => 'file', 'element_type' => 'textmedia', + 'error_code' => 'file_1' ], ] ]; @@ -473,6 +477,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7', ], [ 'record_uid' => 3, @@ -485,6 +490,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => '85', 'link_type' => 'db', 'element_type' => 'textmedia', + 'error_code' => 'page_4' ], [ 'record_uid' => 5, @@ -497,6 +503,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'file:88', 'link_type' => 'file', 'element_type' => 'textmedia', + 'error_code' => 'file_1' ], ] ]; @@ -521,6 +528,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7' ], [ 'record_uid' => 2, @@ -533,6 +541,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7', ], [ 'record_uid' => 3, @@ -545,6 +554,8 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => '85', 'link_type' => 'db', 'element_type' => 'textmedia', + 'error_code' => 'page_4' + ], [ 'record_uid' => 5, @@ -557,6 +568,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'file:88', 'link_type' => 'file', 'element_type' => 'textmedia', + 'error_code' => 'file_1' ], ] ]; @@ -581,6 +593,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7' ], ] ]; @@ -606,6 +619,7 @@ public function getBrokenLinksReturnsCorrectValuesForUserDataProvider(): \Genera 'url' => 'http://localhost/iAmInvalid', 'link_type' => 'external', 'element_type' => 'textmedia', + 'error_code' => 'curl_7' ], ] ]; diff --git a/ext_localconf.php b/ext_localconf.php index be3a3985f..14ae95e43 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -121,4 +121,8 @@ \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:brofix/Resources/Public/Icons/view-table-complex.svg'] ); + + // upgrade wizards + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['brofix_errorCodeUpdateWizard'] + = \Sypets\Brofix\Updates\ErrorCodeUpdateWizard::class; })(); diff --git a/ext_tables.sql b/ext_tables.sql index 6174e037f..0f1a3cd5c 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -14,6 +14,7 @@ CREATE TABLE tx_brofix_broken_links ( link_title text, url text, url_response text, + error_code varchar(30) DEFAULT '' NOT NULL, last_check int(11) DEFAULT '0' NOT NULL, last_check_url int(11) DEFAULT '0' NOT NULL, link_type varchar(50) DEFAULT '' NOT NULL, @@ -30,6 +31,7 @@ CREATE TABLE tx_brofix_link_target_cache ( last_check int(11) unsigned DEFAULT '0' NOT NULL, check_status int(11) unsigned DEFAULT '0' NOT NULL, url_response text, + error_code varchar(30) DEFAULT '' NOT NULL, PRIMARY KEY (uid) );