Skip to content
Snippets Groups Projects
Commit a8a98207 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Exclude deleted records from the update process

To save performance, we exclude deleted records from the update process,
because it is unnecessary to process such records.
parent 1be6944b
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Updates;
use SGalinski\SgMail\Service\BackendService;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\AbstractUpdate;
......@@ -79,7 +80,7 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
continue;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$rowCount = $queryBuilder->select('*')
->from($table)
->where(
......@@ -95,7 +96,7 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
// are the pids not belonging to site root pages ?
foreach ($this->tables as $table) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$result = $queryBuilder->select('pid')
->from($table)
->execute()->fetchAll();
......@@ -126,7 +127,7 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
continue;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$result = $queryBuilder->select('uid', 'site_root_id')
->from($table)
->execute()->fetchAll();
......@@ -147,7 +148,7 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
// check if pid is a site root, if not update it to the nearest one
foreach ($this->tables as $table) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$result = $queryBuilder->select('uid', 'pid')
->from($table)
->execute()->fetchAll();
......@@ -155,7 +156,8 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
/** @var array $result */
foreach ($result as $row) {
$siteRootId = BackendService::getSiteRoot($row[1]);
$siteRootId = BackendService::getSiteRoot($row['pid']);
if ($siteRootId === 0) {
$siteRootId = 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment