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] Remove RealURL migration (#2598) #2602

Open
wants to merge 1 commit 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 0 additions & 166 deletions Classes/Service/SlugService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@

namespace GeorgRinger\News\Service;

use TYPO3\CMS\Core\Context\Context;
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\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class SlugService
Expand Down Expand Up @@ -124,168 +122,4 @@ protected function getUniqueCountStatement(int $uid, int $languageId, string $sl
$queryBuilder->expr()->neq('uid', $queryBuilder->createPositionalParameter($uid, Connection::PARAM_INT))
);
}

/**
* Count valid entries from EXT:realurl table tx_realurl_uniqalias which can be migrated
* Checks also for existance of third party extension table 'tx_realurl_uniqalias'
* EXT:realurl requires not to be installed
*/
public function countOfRealurlAliasMigrations(): int
{
$elementCount = 0;
// Check if table 'tx_realurl_uniqalias' exists
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_realurl_uniqalias');

if ((new (Typo3Version::class))->getVersion() >= 13) {
$schemaManager = $queryBuilder->getConnection()->createSchemaManager();
} else {
$schemaManager = $queryBuilder->getConnection()->getSchemaManager();
}
if ($schemaManager && $schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) {
// Count valid aliases for news
$queryBuilder->getRestrictions()->removeAll();
$elementCount = $queryBuilder->selectLiteral('COUNT(DISTINCT tx_news_domain_model_news.uid)')
->from('tx_realurl_uniqalias')
->join(
'tx_realurl_uniqalias',
'tx_news_domain_model_news',
'tx_news_domain_model_news',
$queryBuilder->expr()->eq(
'tx_realurl_uniqalias.value_id',
$queryBuilder->quoteIdentifier('tx_news_domain_model_news.uid')
)
)
->where(
$queryBuilder->expr()->and(
$queryBuilder->expr()->or(
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.path_segment',
$queryBuilder->createNamedParameter('', Connection::PARAM_STR)
),
$queryBuilder->expr()->isNull('tx_news_domain_model_news.path_segment')
),
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.sys_language_uid',
'tx_realurl_uniqalias.lang'
),
$queryBuilder->expr()->eq(
'tx_realurl_uniqalias.tablename',
$queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)
),
$queryBuilder->expr()->or(
$queryBuilder->expr()->eq(
'tx_realurl_uniqalias.expire',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
),
$queryBuilder->expr()->gte(
'tx_realurl_uniqalias.expire',
$queryBuilder->createNamedParameter(GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'), Connection::PARAM_INT)
)
)
)
)
->executeQuery()->fetchOne();
}
return $elementCount;
}

/**
* Perform migration of EXT:realurl unique alias into empty news slugs
*/
public function performRealurlAliasMigration(): array
{
$databaseQueries = [];

// Check if table 'tx_realurl_uniqalias' exists
$queryBuilderForRealurl = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_realurl_uniqalias');
if ((new (Typo3Version::class))->getVersion() >= 13) {
$schemaManager = $queryBuilderForRealurl->getConnection()->createSchemaManager();
} else {
$schemaManager = $queryBuilderForRealurl->getConnection()->getSchemaManager();
}
if ($schemaManager && $schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) {
/** @var Connection $connection */
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_news_domain_model_news');
$queryBuilder = $connection->createQueryBuilder();

// Get entries to update
$statement = $queryBuilder
->selectLiteral(
'DISTINCT tx_news_domain_model_news.uid, tx_realurl_uniqalias.value_alias, tx_news_domain_model_news.uid, tx_news_domain_model_news.l10n_parent,tx_news_domain_model_news.sys_language_uid'
)
->from('tx_news_domain_model_news')
->join(
'tx_news_domain_model_news',
'tx_realurl_uniqalias',
'tx_realurl_uniqalias',
$queryBuilder->expr()->or(
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.uid',
$queryBuilder->quoteIdentifier('tx_realurl_uniqalias.value_id')
),
$queryBuilder->expr()->and(
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.l10n_parent',
$queryBuilder->quoteIdentifier('tx_realurl_uniqalias.value_id')
),
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.sys_language_uid',
$queryBuilder->quoteIdentifier('tx_realurl_uniqalias.lang')
)
)
)
)
->where(
$queryBuilder->expr()->and(
$queryBuilder->expr()->or(
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.path_segment',
$queryBuilder->createNamedParameter('', Connection::PARAM_STR)
),
$queryBuilder->expr()->isNull('tx_news_domain_model_news.path_segment')
),
$queryBuilder->expr()->eq(
'tx_news_domain_model_news.sys_language_uid',
'tx_realurl_uniqalias.lang'
),
$queryBuilder->expr()->eq(
'tx_realurl_uniqalias.tablename',
$queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)
),
$queryBuilder->expr()->or(
$queryBuilder->expr()->eq(
'tx_realurl_uniqalias.expire',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
),
$queryBuilder->expr()->gte(
'tx_realurl_uniqalias.expire',
$queryBuilder->createNamedParameter(GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'), Connection::PARAM_INT)
)
)
)
)
->executeQuery();

// Update entries
while ($record = $statement->fetchAssociative()) {
$slug = $this->slugService->sanitize((string)$record['value_alias']);
$queryBuilder = $connection->createQueryBuilder();
$queryBuilder->update('tx_news_domain_model_news')
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($record['uid'], Connection::PARAM_INT)
)
)
->set('path_segment', $this->getUniqueValue($record['uid'], $record['sys_language_uid'], $slug));
$databaseQueries[] = $queryBuilder->getSQL();
$queryBuilder->executeStatement();
}
}

return $databaseQueries;
}
}
136 changes: 0 additions & 136 deletions Classes/Updates/RealurlAliasNewsSlugUpdater.php

This file was deleted.

3 changes: 0 additions & 3 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GeorgRinger\News\Hooks\ItemsProcFunc;
use GeorgRinger\News\Hooks\PluginPreviewRenderer;
use GeorgRinger\News\Updates\NewsSlugUpdater;
use GeorgRinger\News\Updates\RealurlAliasNewsSlugUpdater;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use TYPO3\CMS\Core\DependencyInjection\SingletonPass;
Expand All @@ -14,12 +13,10 @@
$containerBuilder->registerForAutoconfiguration(ItemsProcFunc::class)->addTag('news.ItemsProcFunc');
$containerBuilder->registerForAutoconfiguration(PluginPreviewRenderer::class)->addTag('news.PageLayoutView');
$containerBuilder->registerForAutoconfiguration(NewsSlugUpdater::class)->addTag('news.NewsSlugUpdater');
$containerBuilder->registerForAutoconfiguration(RealurlAliasNewsSlugUpdater::class)->addTag('news.RealurlAliasNewsSlugUpdater');

$containerBuilder->addCompilerPass(new SingletonPass('news.NewsFlexFormManipulation'));
$containerBuilder->addCompilerPass(new SingletonPass('news.RecordListQueryHook'));
$containerBuilder->addCompilerPass(new SingletonPass('news.ItemsProcFunc'));
$containerBuilder->addCompilerPass(new SingletonPass('news.PageLayoutView'));
$containerBuilder->addCompilerPass(new SingletonPass('news.NewsSlugUpdater'));
$containerBuilder->addCompilerPass(new SingletonPass('news.RealurlAliasNewsSlugUpdater'));
};
1 change: 0 additions & 1 deletion Documentation/Administration/Migration/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ EXT:news provides a powerful import module which can be used to add news and cat
:titlesonly:

MigrationFromTtNews/Index
MigrationFromRealurl/Index

This file was deleted.

2 changes: 1 addition & 1 deletion Documentation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ uses the latest technologies provided by TYPO3 CMS.
.. card:: :ref:`Administration <admin-manual>`

Install or upgrade EXT:news, learn how to migrate from EXT:tt_news
to news or from RealURL to Routes etc.
to news.

.. card:: :ref:`Reference <reference>`

Expand Down
Loading
Loading