Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sypets committed Mar 18, 2024
1 parent 86229ea commit bec264a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 17 deletions.
70 changes: 67 additions & 3 deletions Classes/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,66 @@ class Configuration
{
public const TRAVERSE_MAX_NUMBER_OF_PAGES_IN_BACKEND_DEFAULT = 1000;

public const DEFAULT_TSCONFIG = [
'searchFields.' => [
'pages' => 'media,url',
'tt_content' => 'bodytext,header_link,records',
],
'excludeCtype' => 'html',
'linktypes' => 'db,file,external,applewebdata',
'check.' => [
'doNotCheckContentOnPagesDoktypes' => '3,4',
'doNotCheckPagesDoktypes' => '6,7,199,255',
'doNotTraversePagesDoktypes' => '6,199,255',
'doNotCheckLinksOnWorkspace' => false,
],
'checkhidden' => false,
'depth' => 999,
'reportHiddenRecords' => true,
'linktypesConfig.' => [
'external.' => [
'headers.' => [
'User-Agent' => '',
'Accept' => '*/*'
],
'timeout' => 10,
'redirects' => 5,
]
],
'excludeLinkTarget.' => [
'storagePid' => 0,
'allowed' => 'external',
],
'linkTargetCache.' => [
'expiresLow' => 604800,
'expiresHigh' => 691200,
],
'crawlDelay.' => [
'seconds' => 5,
'nodelay' => '',
],
'report.' => [
'docsurl' => '',
'recheckButton' => -1,
],
'mail.' => [
'sendOnCheckLinks' => 1,
'recipients' => '',
'fromname' => '',
'fromemail' => '',
'replytoname' => '',
'replytoemail' => '',
'subject' => '',
'template' => 'CheckLinksResults',
'language' => 'en',
],
'custom.' => []
];

/**
* @var mixed[]
*/
protected $tsConfig = [];
protected $tsConfig = self::DEFAULT_TSCONFIG;

/**
* Limit number of pages traversed in backend. This limit is only active when displaying
Expand Down Expand Up @@ -90,7 +146,7 @@ public function __construct(array $extConfArray)
/**
* @var LinktypeInterface $linktype
*/
$linktype = GeneralUtility::makeInstance($className); // @phpstan-ignore-line
$linktype = GeneralUtility::makeInstance($className);
$this->hookObjectsArr[$key] = $linktype;
$linktype->setConfiguration($this);
}
Expand Down Expand Up @@ -122,7 +178,7 @@ public function loadPageTsConfig(int $page): void
* @param string $tsConfigString
* @throws \Exception
*
* @todo Create specific exception
* @todo deprecate, use overrideTsConfigByArray
*/
public function overrideTsConfigByString(string $tsConfigString): void
{
Expand All @@ -147,6 +203,14 @@ public function overrideTsConfigByString(string $tsConfigString): void
}
}

/**
* @param array<mixed> $override
*/
public function overrideTsConfigByArray(array $override): void
{
ArrayUtility::mergeRecursiveWithOverrule($this->tsConfig, $override);
}

/**
* @return mixed[]
*/
Expand Down
2 changes: 0 additions & 2 deletions Classes/Controller/BrokenLinkListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Sypets\Brofix\Controller;

use Psr\Http\Message\ServerRequestInterface;
use Sypets\Brofix\BackendSession\BackendSession;
use Sypets\Brofix\CheckLinks\ExcludeLinkTarget;
use Sypets\Brofix\Configuration\Configuration;
Expand All @@ -24,7 +23,6 @@
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
Expand Down
2 changes: 0 additions & 2 deletions Classes/LinkAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* The TYPO3 project - inspiring people to share!
*/

use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Sypets\Brofix\CheckLinks\CheckLinksStatistics;
Expand Down Expand Up @@ -259,7 +258,6 @@ public function recheckLinks(
$table,
[$field],
$row,
$request,
LinkParser::MASK_CONTENT_CHECK_ALL-LinkParser::MASK_CONTENT_CHECK_IF_EDITABLE_FIELD
);

Expand Down
12 changes: 7 additions & 5 deletions Classes/Parser/LinkParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);
namespace Sypets\Brofix\Parser;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerAwareTrait;
use Sypets\Brofix\Configuration\Configuration;
use Sypets\Brofix\FormEngine\FieldShouldBeChecked;
Expand All @@ -14,7 +13,6 @@
use TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserFactory;
use TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserResult;
use TYPO3\CMS\Core\Html\HtmlParser;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -114,9 +112,8 @@ public function findLinksForRecord(
$table,
array $fields,
array $record,
int $checks = self::MASK_CONTENT_CHECK_ALL,
int $checks = self::MASK_CONTENT_CHECK_ALL
): void {

$idRecord = (int)($record['uid'] ?? 0);
try {
// Put together content of all relevant fields
Expand Down Expand Up @@ -218,6 +215,9 @@ public function findLinksForRecord(
protected function analyzeLinks(SoftReferenceParserResult $parserResult, array &$results, array $record, string $field, string $table): void
{
foreach ($parserResult->getMatchedElements() as $element) {
if (!is_array($element['subst'] ?? false)) {
continue;
}
$r = $element['subst'];
$type = '';
$idRecord = $record['uid'];
Expand Down Expand Up @@ -270,6 +270,9 @@ protected function analyzeTypoLinks(
$referencedRecordType = '';
foreach ($parserResult->getMatchedElements() as $element) {
$type = '';
if (!is_array($element['subst'] ?? false)) {
continue;
}
$r = $element['subst'];
if (empty($r['tokenID']) || substr_count($linkTags[$i], $r['tokenID']) === 0) {
continue;
Expand Down Expand Up @@ -432,5 +435,4 @@ protected function error(string $message): void
$this->logger->error($message);
}
}

}
8 changes: 4 additions & 4 deletions Tests/Functional/LinkAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function testGetLinkStatisticsFindOnlyPageBrokenLinks(string $inputFile,
$this->importDataSet($inputFile);
$this->configuration->setLinkTypes($linkTypes);
$linkAnalyzer = $this->initializeLinkAnalyzer($pidList);
$linkAnalyzer->generateBrokenLinkRecords( $this->configuration->getLinkTypes());
$linkAnalyzer->generateBrokenLinkRecords($this->configuration->getLinkTypes());

// assert
$this->assertCSVDataSet($expectedOutputFile);
Expand Down Expand Up @@ -252,7 +252,7 @@ public function testGetLinkStatisticsFindOnlyExternalBrokenLinksInBodytext(strin
$this->importDataSet($inputFile);
$this->configuration->setLinkTypes($linkTypes);
$linkAnalyzer = $this->initializeLinkAnalyzer($pidList);
$linkAnalyzer->generateBrokenLinkRecords( $this->configuration->getLinkTypes());
$linkAnalyzer->generateBrokenLinkRecords($this->configuration->getLinkTypes());

// assert
$this->assertCSVDataSet($expectedOutputFile);
Expand Down Expand Up @@ -300,7 +300,7 @@ public function testGetLinkStatisticsDoNotDetectCorrectLinksAsBroken(string $inp
// setup
$this->importDataSet($inputFile);
$linkAnalyzer = $this->initializeLinkAnalyzer($pidList);
$linkAnalyzer->generateBrokenLinkRecords( $this->configuration->getLinkTypes());
$linkAnalyzer->generateBrokenLinkRecords($this->configuration->getLinkTypes());

// assert
$this->assertCSVDataSet($expectedOutputFile);
Expand Down Expand Up @@ -364,7 +364,7 @@ public function testGetLinkStatisticsCheckOnlyContentByType(string $inputFile, a
$this->configuration->setLinkTypes($linkTypes);
$this->configuration->setSearchFields($searchFields);
$linkAnalyzer = $this->initializeLinkAnalyzer($pidList);
$linkAnalyzer->generateBrokenLinkRecords( $linkTypes);
$linkAnalyzer->generateBrokenLinkRecords($linkTypes);

// assert
$this->assertCSVDataSet($expectedOutputFile);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Repository/BrokenLinkRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function testGetLinkCountsForPagesAndLinktypesReturnsCorrectCountForUser(
$linkAnalyzer = $this->get(LinkAnalyzer::class);
// @extensionScannerIgnoreLine
$linkAnalyzer->init($pidList, $this->configuration);
$linkAnalyzer->generateBrokenLinkRecords( $linkTypes);
$linkAnalyzer->generateBrokenLinkRecords($linkTypes);

// get result
$result = $this->brokenLinkRepository->getLinkCounts(
Expand Down

0 comments on commit bec264a

Please sign in to comment.