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] Support TYPO3 v13 #40

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 7 additions & 9 deletions Classes/Command/MigrateFieldsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($this->doesRealurlFieldExist($conn)) {
$queryBuilder = $conn->createQueryBuilder();
$queryBuilder->getRestrictions()->removeAll();
$existingRows = $queryBuilder
$existingPages = $queryBuilder
->select('uid')
->from('pages')
->where(
$queryBuilder->expr()->eq('tx_realurl_exclude', $queryBuilder->createNamedParameter(1, Connection::PARAM_INT))
)
->execute()
->fetchAll();
->executeQuery()
->fetchFirstColumn();

if (count($existingRows) === 0) {
if (count($existingPages) === 0) {
$io->success('Nothing done, as there is no row to update.');
return 0;
}

$existingPages = array_column($existingRows, 'uid');

$updateQueryBuilder = $conn->createQueryBuilder();
$affectedRows = $updateQueryBuilder
->update('pages')
->set('exclude_slug_for_subpages', 1)
->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->or(
$queryBuilder->expr()->in(
'uid',
// do not use named parameter here as the list can get too long
Expand All @@ -79,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
)
)
)
->execute();
->executeQuery();

$io->success('Migrated ' . $affectedRows . ' pages (incl. translations)');
} else {
Expand All @@ -96,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
protected function doesRealurlFieldExist(Connection $conn): bool
{
$columns = $conn->getSchemaManager()->listTableColumns('pages');
$columns = $conn->getSchemaInformation()->introspectTable('pages')->getColumns();
foreach ($columns as $column) {
if (strtolower($column->getName()) === 'tx_realurl_exclude') {
return true;
Expand Down
13 changes: 4 additions & 9 deletions Classes/SlugModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -81,17 +80,13 @@ protected function resolveHookParameters(array $configuration, string $tableName
if (isset($record['uid'])) {
// load full record from db (else: it is a new record)
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$stm = $queryBuilder->select('*')
$row = $queryBuilder->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['uid'], Connection::PARAM_INT))
)
->execute();
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$row = $stm->fetch();
} else {
$row = $stm->fetchAssociative();
}
->executeQuery()
->fetchAssociative();
if ($row !== false) {
$this->recordData = array_replace($row, $record);
}
Expand Down Expand Up @@ -162,7 +157,7 @@ protected function regenerateSlug(SlugHelper $helper): string
$slug = $prefix . $slug;
}

return (string)$helper->sanitize($slug);
return $helper->sanitize($slug);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions Classes/Updates/MigrateRealUrlExcludeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

/**
* Command for migrating fields from "pages.tx_realurl_exclude"
* into "pages.exclude_slug_for_subpages".
*/
#[UpgradeWizard('masiMigrateRealUrlExclude')]
class MigrateRealUrlExcludeField implements UpgradeWizardInterface
{
public function getIdentifier(): string
Expand All @@ -44,7 +46,7 @@ protected function getExistingExcludedPages(): array
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
$queryBuilder = $conn->createQueryBuilder();
$queryBuilder->getRestrictions()->removeAll();
$existingRows = $queryBuilder
$excludedPages = $queryBuilder
->select('uid')
->from('pages')
->where(
Expand All @@ -53,11 +55,10 @@ protected function getExistingExcludedPages(): array
$queryBuilder->createNamedParameter(1, Connection::PARAM_INT)
)
)
->execute()
->fetchAll();
->executeQuery()
->fetchFirstColumn();

return array_column($existingRows, 'uid');

return $excludedPages;
}

public function executeUpdate(): bool
Expand All @@ -82,15 +83,15 @@ public function executeUpdate(): bool
array_merge($existingPages, [0])
)
)
->execute();
->executeQuery();

return true;
}

protected function doesRealurlFieldExist(): bool
{
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
$columns = $conn->getSchemaManager()->listTableColumns('pages');
$columns = $conn->getSchemaInformation()->introspectTable('pages')->getColumns();
foreach ($columns as $column) {
if (strtolower($column->getName()) === 'tx_realurl_exclude') {
return true;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"homepage": "https://github.com/b13/masi",
"license": ["GPL-2.0-or-later"],
"require": {
"php": "^7.4 || ~8.0",
"typo3/cms-core": "^10.4 || ^11.5 || ^12.0"
"php": "~8.1",
"typo3/cms-core": "^12.4 || ^13.0"
},
"replace": {
"typo3-ter/masi": "self.version"
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'version' => '2.0.3',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-12.99.99',
'typo3' => '12.4.0-13.4.99',
],
],
];
9 changes: 0 additions & 9 deletions ext_localconf.php

This file was deleted.