Skip to content

Commit

Permalink
[FEATURE] Inform when pages does not exists when calling crawler:buil…
Browse files Browse the repository at this point in the history
…dQueue from cli (#1098)
  • Loading branch information
tomasnorre authored Oct 6, 2024
1 parent 2ce75a8 commit 8ad77e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added
* Possibility to flush all processes from the backend module in process view
* Information when page does not exists when crawler:buildQueue command is called from cli

### Changed

Expand Down
10 changes: 6 additions & 4 deletions Classes/Command/BuildQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
Expand Down Expand Up @@ -122,13 +123,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$crawlerController = GeneralUtility::makeInstance(CrawlerController::class);
/** @var QueueRepository $queueRepository */
$queueRepository = GeneralUtility::makeInstance(QueueRepository::class);
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);

if ($mode === 'exec') {
$crawlerController->registerQueueEntriesInternallyOnly = true;
}

$pageId = MathUtility::forceIntegerInRange((int) $input->getArgument('page'), 0);
if ($pageId === 0) {
if ($pageId === 0 || empty($pageRepository->getPage($pageId))) {
$message = "Page {$pageId} is not a valid page, please check you root page id and try again.";
MessageUtility::addErrorMessage($message);
$output->writeln("<info>{$message}</info>");
Expand Down Expand Up @@ -188,9 +190,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$progressBar->clear();
if (is_array($requestResult)) {
$resLog = array_key_exists('log', $requestResult)
&& is_array($requestResult['log']) ? PHP_EOL . chr(9) . chr(9) .
&& is_array($requestResult['log']) ? chr(9) . chr(9) .
implode(PHP_EOL . chr(9) . chr(9), $requestResult['log']) : '';
$output->writeln('<info>OK: ' . $resLog . '</info>' . PHP_EOL);
$output->writeln('<info>OK: ' . $resLog . '</info>');
} else {
$output->writeln(
'<error>Error checking Crawler Result: ' . substr(
Expand Down Expand Up @@ -236,7 +238,7 @@ private function outputUrls(array $queueRows, OutputInterface $output): void
if (empty($row->message)) {
$output->writeln('<info>' . $row->urls . '</info>');
} else {
$output->writeln('<warning>' . $row->pageTitle . ': ' . $row->message . '</warning>');
$output->writeln('<comment>' . $row->pageTitle . ': ' . $row->message . '</comment>');
}
}
}
Expand Down

0 comments on commit 8ad77e0

Please sign in to comment.