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

[TASK] Cherry-Pick relevant changes from release-12.0.x into main #4238

Merged
Merged
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/.github export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/Build/ export-ignore
/CONTRIBUTING.md export-ignore
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ jobs:
echo "Current Size of EXT:Solr build Artefacts after run: " \
&& sudo du -sh "${{ env.CI_BUILD_DIRECTORY }}" \
&& sudo du -sh ${{ env.CI_BUILD_DIRECTORY }}/*
-
name: Upload code coverage to Scrutinizer
run: |
ocular code-coverage:upload --format=php-clover coverage.unit.clover
ocular code-coverage:upload --format=php-clover coverage.integration.clover
-
name: Clean up
run: |
Expand Down
29 changes: 0 additions & 29 deletions .scrutinizer.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Build/Test/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fi

echo "Install third party tools globally:"
export PATH=$PATH:$(composer config --global home)/vendor/bin
if ! composer global require sclable/xml-lint scrutinizer/ocular --ignore-platform-reqs
if ! composer global require sclable/xml-lint --ignore-platform-reqs
then
"The test environment could not be installed by composer as expected. Please fix this issue."
exit 1
Expand Down
4 changes: 2 additions & 2 deletions Build/Test/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi

echo -e "\n\n"
echo "Run unit tests"
if ! composer tests:unit -- --coverage-clover=coverage.unit.clover
if ! composer tests:unit
then
echo "Error during running the unit tests please check and fix them"
EXIT_CODE=5
Expand Down Expand Up @@ -95,7 +95,7 @@ fi

echo -e "\n\n"
echo "Run integration tests"
if ! composer tests:integration -- --coverage-clover=coverage.integration.clover
if ! composer tests:integration
then
echo "Error during running the integration tests please check and fix them"
EXIT_CODE=6
Expand Down
27 changes: 25 additions & 2 deletions Classes/Domain/Index/Queue/GarbageRemover/AbstractStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use ApacheSolrForTypo3\Solr\ConnectionManager;
use ApacheSolrForTypo3\Solr\Domain\Site\Exception\UnexpectedTYPO3SiteInitializationException;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\GarbageCollectorPostProcessor;
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
Expand All @@ -33,15 +34,17 @@
abstract class AbstractStrategy
{
protected QueueInterface $queue;

protected ConnectionManager $connectionManager;
protected SiteRepository $siteRepository;

public function __construct(
QueueInterface $queue = null,
ConnectionManager $connectionManager = null,
SiteRepository $siteRepository = null,
) {
$this->queue = $queue ?? GeneralUtility::makeInstance(Queue::class);
$this->connectionManager = $connectionManager ?? GeneralUtility::makeInstance(ConnectionManager::class);
$this->siteRepository = $siteRepository ?? GeneralUtility::makeInstance(SiteRepository::class);
}

/**
Expand Down Expand Up @@ -90,8 +93,13 @@ protected function deleteInSolrAndUpdateIndexQueue(string $table, int $uid): voi
*/
protected function deleteIndexDocuments(string $table, int $uid, int $language = 0): void
{
// record can be indexed for multiple sites
$indexQueueItems = $this->queue->getItems($table, $uid);
if ($indexQueueItems === []) {
$this->deleteRecordInAllSites($table, $uid);
return;
}

// record can be indexed for multiple sites
foreach ($indexQueueItems as $indexQueueItem) {
try {
$site = $indexQueueItem->getSite();
Expand All @@ -115,6 +123,21 @@ protected function deleteIndexDocuments(string $table, int $uid, int $language =
}
}

protected function deleteRecordInAllSites(string $table, int $uid): void
{
$sites = $this->siteRepository->getAvailableSites();
foreach ($sites as $site) {
$solrConnections = $this->connectionManager->getConnectionsBySite($site);
$this->deleteRecordInAllSolrConnections(
$table,
$uid,
$solrConnections,
$site->getSiteHash(),
$site->getSolrConfiguration()->getEnableCommits()
);
}
}

/**
* Deletes the record in all solr connections from that site.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -130,9 +133,26 @@ protected function getRecordForIndexConfigurationIsValid(
return $row;
}

$row = BackendUtility::getRecord($recordTable, $recordUid, '*', $recordWhereClause) ?? [];
$cache->set($cacheId, $row);
$queryBuilder = $this->getQueryBuilderForTable($recordTable);
$queryBuilder
->select('*')
->from($recordTable)
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($recordUid, Connection::PARAM_INT)
)
);

if ($recordWhereClause !== '') {
$queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($recordWhereClause));
}

$row = $queryBuilder->executeQuery()->fetchAssociative();
if ($row === false) {
$row = [];
}
$cache->set($cacheId, $row);
return $row;
}

Expand All @@ -154,4 +174,9 @@ protected function isValidTableForIndexConfigurationName(

return false;
}

protected static function getQueryBuilderForTable(string $table): QueryBuilder
{
return GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
}
}
20 changes: 13 additions & 7 deletions Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function handlePageUpdate(int $uid, array $updatedFields = []): void
}

if ($pid === null) {
$this->removeFromIndexAndQueueWhenItemInQueue('pages', $uid);
$this->removeFromIndexAndQueue('pages', $uid);
return;
}

Expand Down Expand Up @@ -284,7 +284,7 @@ protected function applyPageChangesToQueue(int $uid): void
$this->mountPageUpdater->update($uid);
$this->indexQueue->updateItem('pages', $uid);
} else {
$this->removeFromIndexAndQueueWhenItemInQueue('pages', $uid);
$this->removeFromIndexAndQueue('pages', $uid);
}
}

Expand All @@ -307,7 +307,7 @@ protected function applyRecordChangesToQueue(string $table, int $uid, int $pid):
$this->indexQueue->updateItem($table, $uid);
} else {
// TODO should be moved to garbage collector
$this->removeFromIndexAndQueueWhenItemInQueue($table, $uid);
$this->removeFromIndexAndQueue($table, $uid);
}
}
}
Expand All @@ -324,9 +324,17 @@ protected function removeFromIndexAndQueue(string $recordTable, int $recordUid):
* Removes record from the index queue and from the solr index when the item is in the queue.
*
* @throws DBALException
* @deprecated DataUpdateHandler->removeFromIndexAndQueueWhenItemInQueue is deprecated and will be removed in v13.
Use DataUpdateHandler->removeFromIndexAndQueue instead.
*/
protected function removeFromIndexAndQueueWhenItemInQueue(string $recordTable, int $recordUid): void
{
trigger_error(
'DataUpdateHandler->removeFromIndexAndQueueWhenItemInQueue is deprecated and will be removed in v13.'
. ' Use DataUpdateHandler->removeFromIndexAndQueue instead.',
E_USER_DEPRECATED
);

if (!$this->indexQueue->containsItem($recordTable, $recordUid)) {
return;
}
Expand Down Expand Up @@ -406,7 +414,7 @@ protected function processPageRecord(int $uid, int $pid, array $updatedFields =
protected function processRecord(string $recordTable, int $recordUid, array $rootPageIds): void
{
if (empty($rootPageIds)) {
$this->removeFromIndexAndQueueWhenItemInQueue($recordTable, $recordUid);
$this->removeFromIndexAndQueue($recordTable, $recordUid);
return;
}

Expand All @@ -424,9 +432,7 @@ protected function processRecord(string $recordTable, int $recordUid, array $roo

$record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $solrConfiguration);
if (empty($record)) {
// TODO move this part to the garbage collector
// check if the item should be removed from the index because it no longer matches the conditions
$this->removeFromIndexAndQueueWhenItemInQueue($recordTable, $recordUid);
// skip processing, queue and index entry will be removed by garbage collection triggered via RecordGarbageCheckEvent
continue;
}
// Clear existing index queue items to prevent mount point duplicates.
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ public function performRecordGarbageCheck(
): void {
$record = $this->getRecordWithFieldRelevantForGarbageCollection($table, $uid);

// If no record could be found skip further processing
// If no record could be found, remove remains from index and queue
if (empty($record)) {
$this->collectGarbage($table, $uid);
return;
}

Expand Down
6 changes: 4 additions & 2 deletions Classes/System/Url/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public function withoutQueryParameter(string $parameterName): UrlHelper
/**
* Add a given parameter with value to the query and create a new instance.
*/
public function withQueryParameter(string $parameterName, $value): UrlHelper
{
public function withQueryParameter(
string $parameterName,
mixed $value,
): UrlHelper {
parse_str($this->query, $parameters);
$parameters[$parameterName] = $value;
$query = http_build_query($parameters);
Expand Down
22 changes: 21 additions & 1 deletion Classes/ViewHelpers/SearchFormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function initializeArguments(): void
}

/**
* Render search form tag
* Renders search form-tag
*
* @throws AspectNotFoundException
* @noinspection PhpMissingReturnTypeInspection
Expand Down Expand Up @@ -110,12 +110,32 @@ public function render()
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('q', $this->getQueryString());
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('pageUid', $pageUid);
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add(
'languageUid',
(
$this->renderingContext
->getAttribute(ServerRequestInterface::class)
->getAttribute('language')
?->getLanguageId() ?? 0
)
);
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('existingParameters', $this->getExistingSearchParameters());
// @extensionScannerIgnoreLine
// Added addPageAndLanguageId for compatibility
$this->getTemplateVariableContainer()->add('addPageAndLanguageId', false);
$formContent = $this->renderChildren();
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('addPageAndLanguageId');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('q');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('pageUid');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('languageUid');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('existingParameters');

$this->tag->setContent($formContent);
Expand Down
4 changes: 2 additions & 2 deletions Docker/SolrServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM solr:9.7.0
MAINTAINER dkd Internet Service GmbH <[email protected]>
ENV TERM linux
LABEL org.opencontainers.image.authors="dkd Internet Service GmbH [email protected]"
ENV TERM=linux

ARG SOLR_UNIX_UID="8983"
ARG SOLR_UNIX_GID="8983"
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Appendix/VersionMatrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ List of EXT:solr versions and the matching versions of Apache Solr and TYPO3 tha
TYPO3 EXT:solr EXT:tika EXT:solrfal EXT:solrconsole EXT:solrdebugtools EXT:solrfluidgrouping EXT:solrmlt Apache Solr Configset
========= ========== ========== =========== =============== ================== ================================ =============== =============== =================
13.4 13.0 (ᾱ) 13.0 (Ø) 13.0 (ᾱ) 13.0 (Ø) 13.0 (Ø) N/A (integrated in EXT:solr) 13.0 (Ø) 9.7.0¹ ext_solr_13_0_0
12.4 12.0 12.0 12.0 12.0 12.0 N/A (integrated in EXT:solr) 12.0 (Ø) 9.6.1¹ ext_solr_12_0_0
12.4 12.0 12.0 12.0 12.0 12.0 N/A (integrated in EXT:solr) 12.0 (Ø) 9.7.0¹ ext_solr_12_0_0
========= ========== ========== =========== =============== ================== ================================ =============== =============== =================

| Ø - not yet available
Expand Down
Loading