Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Add record to index queue when published #3938

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Used versions (please complete the following information):**
- TYPO3 Version: [e.g. 12.4.11]
- TYPO3 Version: [e.g. 13.4.0]
- Browser: [e.g. chrome, safari]
- EXT:solr Version: [e.g. 12.0.2]
- EXT:solr Version: [e.g. 13.0.0]
- Used Apache Solr Version: [e.g. 9.6.0]
- PHP Version: [e.g. 8.2.0]
- MySQL Version: [e.g. 8.0.0]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-matrix.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"release-12.0.x": {
"PHP": [ "8.1", "8.2", "8.3" ],
"TYPO3": [ "12", "12.4.x-dev" ]
"main": {
"PHP": [ "8.2", "8.3" ],
"TYPO3": [ "dev-main" ]
}
}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: build

on:
push:
branches: [ main, release-12.0.x ]
branches: [ main, release-13.0.x, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ]
tags:
- "**"
pull_request:
branches: [ main, release-12.0.x ]
branches: [ main, release-13.0.x, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ]

env:
CI_BUILD_DIRECTORY: '/home/runner/work/ext-solr/ext-solr/.Build'
Expand Down
4 changes: 2 additions & 2 deletions Build/Test/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

DEFAULT_TYPO3_VERSION="12"
DEFAULT_TYPO3_VERSION="13"
DEFAULT_TYPO3_DATABASE_HOST="localhost"
DEFAULT_TYPO3_DATABASE_NAME="test"
DEFAULT_TYPO3_DATABASE_USERNAME="root"
Expand Down Expand Up @@ -42,7 +42,7 @@ if [[ $* == *--local* ]]; then
fi

if [ -z $TYPO3_VERSION ]; then
echo "Must set env var TYPO3_VERSION (e.g. dev-main or ^12.4)"
echo "Must set env var TYPO3_VERSION (e.g. dev-main or ^13)"
exit 1
fi

Expand Down
11 changes: 4 additions & 7 deletions Classes/ContentObject/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use ApacheSolrForTypo3\Solr\System\TCA\TCAService;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Result;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\RelationHandler;
Expand Down Expand Up @@ -394,19 +395,15 @@ protected function sortByKeyInIN(Result $statement, string $columnName, ...$arra
}

/**
* Returns current language id fetched from the SiteLanguage
*
* @throws ContentRenderingException
* Returns current language id fetched from the Context
*/
protected function getLanguageUid(): int
{
return $this->getTypoScriptFrontendController()->getLanguage()->getLanguageId();
return GeneralUtility::makeInstance(Context::class)->getAspect('language')->get('id');
}

/**
* Returns and sets FrontendOverlayService instance to this object.
*
* @throws ContentRenderingException
*/
protected function getFrontendOverlayService(): FrontendOverlayService
{
Expand All @@ -417,7 +414,7 @@ protected function getFrontendOverlayService(): FrontendOverlayService
return $this->frontendOverlayService = GeneralUtility::makeInstance(
FrontendOverlayService::class,
$this->tcaService,
$this->getTypoScriptFrontendController()
GeneralUtility::makeInstance(Context::class)
);
}
}
16 changes: 4 additions & 12 deletions Classes/Controller/AbstractBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

/**
* Class AbstractBaseController
Expand All @@ -44,8 +43,6 @@ abstract class AbstractBaseController extends ActionController

private ?ContentObjectRenderer $contentObjectRenderer = null;

protected ?TypoScriptFrontendController $typoScriptFrontendController = null;

private ?SolrConfigurationManager $solrConfigurationManager = null;

/**
Expand All @@ -62,7 +59,6 @@ abstract class AbstractBaseController extends ActionController
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
{
$this->configurationManager = $configurationManager;
$this->contentObjectRenderer = $this->configurationManager->getContentObject();
$this->arguments = GeneralUtility::makeInstance(Arguments::class);
}

Expand Down Expand Up @@ -91,10 +87,7 @@ public function setResetConfigurationBeforeInitialize(bool $resetConfigurationBe
*/
protected function initializeAction(): void
{
// Reset configuration (to reset flexform overrides) if resetting is enabled
if ($this->resetConfigurationBeforeInitialize) {
$this->solrConfigurationManager->reset();
}
$this->contentObjectRenderer = $this->request->getAttribute('currentContentObject', $this->contentObjectRenderer);
/** @var TypoScriptService $typoScriptService */
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);

Expand All @@ -107,7 +100,7 @@ protected function initializeAction(): void
}
}

$this->typoScriptConfiguration = $this->solrConfigurationManager->getTypoScriptConfiguration();
$this->typoScriptConfiguration = $this->solrConfigurationManager->getTypoScriptFromRequest($this->request);
if ($pluginSettings !== []) {
$this->typoScriptConfiguration->mergeSolrConfiguration(
$typoScriptService->convertPlainArrayToTypoScriptArray($pluginSettings),
Expand All @@ -125,7 +118,6 @@ protected function initializeAction(): void
}

parent::initializeAction();
$this->typoScriptFrontendController = $GLOBALS['TSFE'];
$this->initializeSettings();

if ($this->actionMethodName !== 'solrNotAvailableAction') {
Expand Down Expand Up @@ -154,8 +146,8 @@ protected function initializeSearch(): void
{
try {
$solrConnection = GeneralUtility::makeInstance(ConnectionManager::class)->getConnectionByTypo3Site(
$this->typoScriptFrontendController->getSite(),
$this->typoScriptFrontendController->getLanguage()->getLanguageId()
$this->request->getAttribute('site'),
(int)$this->request->getAttribute('language')?->getLanguageId(),
);

$search = GeneralUtility::makeInstance(Search::class, $solrConnection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ protected function initializeView($view): void
parent::initializeView($view);

$this->generateCoreSelectorMenuUsingPageTree();
$coreOptimizationTabs = $this->moduleTemplate->getDynamicTabMenu([], 'coreOptimization');
$this->moduleTemplate->assign('tabs', $coreOptimizationTabs);
}

/**
Expand Down Expand Up @@ -295,7 +293,7 @@ public function saveStopWordsAction(string $stopWords, bool $replaceStopwords =
protected function exportFile(string $content, string $type = 'synonyms', string $fileExtension = 'txt'): ResponseInterface
{
$coreAdmin = $this->selectedSolrCoreConnection->getAdminService();
return $this->responseFactory->createResponse()
return $this->responseFactory->createResponse()
->withHeader('Content-Type', 'text/plain; charset=utf-8')
->withHeader('Cache-control', 'public')
->withHeader('Content-Description', 'File transfer')
Expand Down
9 changes: 5 additions & 4 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public function resultsAction(): ResponseInterface

try {
$arguments = $this->request->getArguments();
$pageId = $this->typoScriptFrontendController->getRequestedId();
$languageId = $this->typoScriptFrontendController->getLanguage()->getLanguageId();

$pageId = $this->request->getAttribute('routing')->getPageId();
$languageId = $this->request->getAttribute('language')->getLanguageId();
$searchRequest = $this->getSearchRequestBuilder()->buildForSearch($arguments, $pageId, $languageId);

$searchResultSet = $this->searchService->search($searchRequest);
Expand Down Expand Up @@ -197,8 +198,8 @@ public function frequentlySearchedAction(): ResponseInterface
/** @var SearchResultSet $searchResultSet */
$searchResultSet = GeneralUtility::makeInstance(SearchResultSet::class);

$pageId = $this->typoScriptFrontendController->getRequestedId();
$languageId = $this->typoScriptFrontendController->getLanguage()->getLanguageId();
$pageId = $this->request->getAttribute('routing')->getPageId();
$languageId = $this->request->getAttribute('language')->getLanguageId();
$searchRequest = $this->getSearchRequestBuilder()->buildForFrequentSearches($pageId, $languageId);
$searchResultSet->setUsedSearchRequest($searchRequest);

Expand Down
7 changes: 3 additions & 4 deletions Classes/Controller/SuggestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ public function suggestAction(string $queryString, ?string $callback = null, ?ar
/** @var SuggestService $suggestService */
$suggestService = GeneralUtility::makeInstance(
SuggestService::class,
$this->typoScriptFrontendController,
$this->searchService,
$this->typoScriptConfiguration
);

$additionalFilters = is_array($additionalFilters) ? array_map('htmlspecialchars', $additionalFilters) : [];
$pageId = $this->typoScriptFrontendController->getRequestedId();
$languageId = $this->typoScriptFrontendController->getLanguage()->getLanguageId();
$pageId = $this->request->getAttribute('routing')->getPageId();
$languageId = $this->request->getAttribute('language')?->getLanguageId();
$arguments = $this->request->getArguments();

$searchRequest = $this->getSearchRequestBuilder()->buildForSuggest($arguments, $rawQuery, $pageId, $languageId);
$result = $suggestService->getSuggestions($searchRequest, $additionalFilters);
$result = $suggestService->getSuggestions($this->request, $searchRequest, $additionalFilters);
} catch (SolrUnavailableException) {
return $this->handleSolrUnavailable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository;
use Doctrine\DBAL\Exception as DBALException;
use PDO;
use Doctrine\DBAL\ParameterType;

/**
* Class IndexQueueIndexingPropertyRepository
Expand All @@ -40,11 +40,11 @@ public function removeByRootPidAndIndexQueueUid(int $rootPid, int $indexQueueUid
->where(
$queryBuilder->expr()->eq(
'root',
$queryBuilder->createNamedParameter($rootPid, PDO::PARAM_INT)
$queryBuilder->createNamedParameter($rootPid, ParameterType::INTEGER)
),
$queryBuilder->expr()->eq(
'item_id',
$queryBuilder->createNamedParameter($indexQueueUid, PDO::PARAM_INT)
$queryBuilder->createNamedParameter($indexQueueUid, ParameterType::INTEGER)
)
)->executeStatement();
}
Expand All @@ -71,7 +71,7 @@ public function findAllByIndexQueueUid(int $indexQueueUid): array
->where(
$queryBuilder->expr()->eq(
'item_id',
$queryBuilder->createNamedParameter($indexQueueUid, PDO::PARAM_INT)
$queryBuilder->createNamedParameter($indexQueueUid, ParameterType::INTEGER)
)
)->executeQuery()
->fetchAllAssociative();
Expand Down
19 changes: 9 additions & 10 deletions Classes/Domain/Index/Queue/QueueItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository;
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
use Doctrine\DBAL\Exception as DBALException;
use PDO;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
Expand Down Expand Up @@ -242,7 +241,7 @@ public function getPageItemChangedTimeByPageUid(int $pageUid): ?int
->getQueryBuilderForTable('tt_content');
$queryBuilder->getRestrictions()->removeAll();
$pageContentLastChangedTime = $queryBuilder
->add('select', $queryBuilder->expr()->max('tstamp', 'changed_time'))
->selectLiteral($queryBuilder->expr()->max('tstamp', 'changed_time'))
->from('tt_content')
->where(
$queryBuilder->expr()->eq('pid', $pageUid)
Expand Down Expand Up @@ -270,7 +269,7 @@ public function getLocalizableItemChangedTime(string $itemType, int $itemUid): i
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($itemType);
$queryBuilder->getRestrictions()->removeAll();
$localizedChangedTime = $queryBuilder
->add('select', $queryBuilder->expr()->max($timeStampField, 'changed_time'))
->selectLiteral($queryBuilder->expr()->max($timeStampField, 'changed_time'))
->from($itemType)
->orWhere(
$queryBuilder->expr()->eq('uid', $itemUid),
Expand Down Expand Up @@ -552,7 +551,7 @@ public function findItemsByItemTypeAndItemUid(string $itemType, int $itemUid): a
{
$queryBuilder = $this->getQueryBuilder();
$compositeExpression = $queryBuilder->expr()->and(
$queryBuilder->expr()->eq('item_type', $queryBuilder->getConnection()->quote($itemType, PDO::PARAM_STR)),
$queryBuilder->expr()->eq('item_type', $queryBuilder->getConnection()->quote($itemType)),
$queryBuilder->expr()->eq('item_uid', $itemUid)
);
return $this->getItemsByCompositeExpression($compositeExpression, $queryBuilder);
Expand Down Expand Up @@ -616,7 +615,7 @@ public function findItemsToIndex(Site $site, int $limit = 50): array
$indexQueueItemRecords = $queryBuilder
->select('*')
->from($this->table)
->andWhere(
->where(
$queryBuilder->expr()->eq('root', $site->getRootPageId()),
$queryBuilder->expr()->gt('changed', 'indexed'),
$queryBuilder->expr()->lte('changed', time()),
Expand Down Expand Up @@ -815,7 +814,7 @@ public function findPageIdsOfExistingMountPagesByMountIdentifier(string $mountPo
$queryBuilder = $this->getQueryBuilder();
$resultSet = $queryBuilder
->select('item_uid')
->add('select', $queryBuilder->expr()->count('*', 'queueItemCount'), true)
->addSelectLiteral($queryBuilder->expr()->count('*', 'queueItemCount'))
->from($this->table)
->where(
$queryBuilder->expr()->eq('item_type', $queryBuilder->createNamedParameter('pages')),
Expand Down Expand Up @@ -849,10 +848,10 @@ public function findAllIndexQueueItemsByRootPidAndMountIdentifierAndMountedPids(
->select('*')
->from($this->table)
->where(
$queryBuilder->expr()->eq('root', $queryBuilder->createNamedParameter($rootPid, PDO::PARAM_INT)),
$queryBuilder->expr()->eq('root', $queryBuilder->createNamedParameter($rootPid, \Doctrine\DBAL\ParameterType::INTEGER)),
$queryBuilder->expr()->eq('item_type', $queryBuilder->createNamedParameter('pages')),
$queryBuilder->expr()->in('item_uid', $mountedPids),
$queryBuilder->expr()->eq('has_indexing_properties', $queryBuilder->createNamedParameter(1, PDO::PARAM_INT)),
$queryBuilder->expr()->eq('has_indexing_properties', $queryBuilder->createNamedParameter(1, \Doctrine\DBAL\ParameterType::INTEGER)),
$queryBuilder->expr()->eq('pages_mountidentifier', $queryBuilder->createNamedParameter($mountPointIdentifier))
)
->executeQuery()
Expand All @@ -868,11 +867,11 @@ public function updateHasIndexingPropertiesFlagByItemUid(int $itemUid, bool $has
return $queryBuilder
->update($this->table)
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($itemUid, PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($itemUid, \Doctrine\DBAL\ParameterType::INTEGER))
)
->set(
'has_indexing_properties',
$queryBuilder->createNamedParameter($hasIndexingPropertiesFlag, PDO::PARAM_INT),
$queryBuilder->createNamedParameter($hasIndexingPropertiesFlag, \Doctrine\DBAL\ParameterType::INTEGER),
false
)->executeStatement();
}
Expand Down
26 changes: 14 additions & 12 deletions Classes/Domain/Index/Queue/Statistic/QueueStatisticsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository;
use Doctrine\DBAL\Exception as DBALException;
use PDO;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException;

Expand Down Expand Up @@ -47,19 +46,22 @@ public function findOneByRootPidAndOptionalIndexingConfigurationName(
): QueueStatistic {
$queryBuilder = $this->getQueryBuilder();
$queryBuilder
->add('select', vsprintf('(%s < %s) AS %s', [
$queryBuilder->quoteIdentifier($this->columnIndexed),
$queryBuilder->quoteIdentifier($this->columnChanged),
$queryBuilder->quoteIdentifier('pending'),
]), true)
->add('select', vsprintf('(%s) AS %s', [
$queryBuilder->expr()->notLike($this->columnErrors, $queryBuilder->createNamedParameter('')),
$queryBuilder->quoteIdentifier('failed'),
]), true)
->add('select', $queryBuilder->expr()->count('*', 'count'), true)
->getConcreteQueryBuilder()
->select(
vsprintf('(%s < %s) AS %s', [
$queryBuilder->quoteIdentifier($this->columnIndexed),
$queryBuilder->quoteIdentifier($this->columnChanged),
$queryBuilder->quoteIdentifier('pending'),
]),
vsprintf('(%s) AS %s', [
$queryBuilder->expr()->notLike($this->columnErrors, $queryBuilder->createNamedParameter('')),
$queryBuilder->quoteIdentifier('failed'),
]),
$queryBuilder->expr()->count('*', 'count')
)
->from($this->table)
->where(
$queryBuilder->expr()->eq($this->columnRootpage, $queryBuilder->createNamedParameter($rootPid, PDO::PARAM_INT))
$queryBuilder->expr()->eq($this->columnRootpage, $queryBuilder->createNamedParameter($rootPid, \Doctrine\DBAL\ParameterType::INTEGER))
)->groupBy('pending', 'failed');

if (!empty($indexingConfigurationName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ protected function processPageRecord(int $uid, int $pid, array $updatedFields =
$this->updateCanonicalPages($uid);
$this->mountPageUpdater->update($uid);

// We need to get the full record to find out if this is a page translation
$fullRecord = BackendUtility::getRecord('pages', $uid);
if ($fullRecord['sys_language_uid'] > 0) {
$uid = (int)$fullRecord['l10n_parent'];
}

$recursiveUpdateRequired = $this->isRecursivePageUpdateRequired($uid, $updatedFields);
if ($recursiveUpdateRequired) {
$treePageIds = $this->getSubPageIds($uid);
Expand Down
Loading
Loading