Skip to content

Commit 2179d13

Browse files
authored
Merge pull request #40 from christophlehmann/typo3-13
[TASK] Support TYPO3 v13
2 parents a31205b + 2cdd0e9 commit 2179d13

File tree

6 files changed

+22
-37
lines changed

6 files changed

+22
-37
lines changed

Classes/Command/MigrateFieldsCommand.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4646
if ($this->doesRealurlFieldExist($conn)) {
4747
$queryBuilder = $conn->createQueryBuilder();
4848
$queryBuilder->getRestrictions()->removeAll();
49-
$existingRows = $queryBuilder
49+
$existingPages = $queryBuilder
5050
->select('uid')
5151
->from('pages')
5252
->where(
5353
$queryBuilder->expr()->eq('tx_realurl_exclude', $queryBuilder->createNamedParameter(1, Connection::PARAM_INT))
5454
)
55-
->execute()
56-
->fetchAll();
55+
->executeQuery()
56+
->fetchFirstColumn();
5757

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

63-
$existingPages = array_column($existingRows, 'uid');
64-
6563
$updateQueryBuilder = $conn->createQueryBuilder();
6664
$affectedRows = $updateQueryBuilder
6765
->update('pages')
6866
->set('exclude_slug_for_subpages', 1)
6967
->where(
70-
$queryBuilder->expr()->orX(
68+
$queryBuilder->expr()->or(
7169
$queryBuilder->expr()->in(
7270
'uid',
7371
// do not use named parameter here as the list can get too long
@@ -79,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7977
)
8078
)
8179
)
82-
->execute();
80+
->executeQuery();
8381

8482
$io->success('Migrated ' . $affectedRows . ' pages (incl. translations)');
8583
} else {
@@ -96,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9694
*/
9795
protected function doesRealurlFieldExist(Connection $conn): bool
9896
{
99-
$columns = $conn->getSchemaManager()->listTableColumns('pages');
97+
$columns = $conn->getSchemaInformation()->introspectTable('pages')->getColumns();
10098
foreach ($columns as $column) {
10199
if (strtolower($column->getName()) === 'tx_realurl_exclude') {
102100
return true;

Classes/SlugModifier.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use TYPO3\CMS\Core\Database\Connection;
1616
use TYPO3\CMS\Core\Database\ConnectionPool;
1717
use TYPO3\CMS\Core\DataHandling\SlugHelper;
18-
use TYPO3\CMS\Core\Information\Typo3Version;
1918
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
2019
use TYPO3\CMS\Core\Utility\GeneralUtility;
2120

@@ -81,17 +80,13 @@ protected function resolveHookParameters(array $configuration, string $tableName
8180
if (isset($record['uid'])) {
8281
// load full record from db (else: it is a new record)
8382
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
84-
$stm = $queryBuilder->select('*')
83+
$row = $queryBuilder->select('*')
8584
->from('pages')
8685
->where(
8786
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['uid'], Connection::PARAM_INT))
8887
)
89-
->execute();
90-
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
91-
$row = $stm->fetch();
92-
} else {
93-
$row = $stm->fetchAssociative();
94-
}
88+
->executeQuery()
89+
->fetchAssociative();
9590
if ($row !== false) {
9691
$this->recordData = array_replace($row, $record);
9792
}
@@ -162,7 +157,7 @@ protected function regenerateSlug(SlugHelper $helper): string
162157
$slug = $prefix . $slug;
163158
}
164159

165-
return (string)$helper->sanitize($slug);
160+
return $helper->sanitize($slug);
166161
}
167162

168163
/**

Classes/Updates/MigrateRealUrlExcludeField.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
use TYPO3\CMS\Core\Database\Connection;
1616
use TYPO3\CMS\Core\Database\ConnectionPool;
1717
use TYPO3\CMS\Core\Utility\GeneralUtility;
18+
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
1819
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
1920
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
2021

2122
/**
2223
* Command for migrating fields from "pages.tx_realurl_exclude"
2324
* into "pages.exclude_slug_for_subpages".
2425
*/
26+
#[UpgradeWizard('masiMigrateRealUrlExclude')]
2527
class MigrateRealUrlExcludeField implements UpgradeWizardInterface
2628
{
2729
public function getIdentifier(): string
@@ -44,7 +46,7 @@ protected function getExistingExcludedPages(): array
4446
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
4547
$queryBuilder = $conn->createQueryBuilder();
4648
$queryBuilder->getRestrictions()->removeAll();
47-
$existingRows = $queryBuilder
49+
$excludedPages = $queryBuilder
4850
->select('uid')
4951
->from('pages')
5052
->where(
@@ -53,11 +55,10 @@ protected function getExistingExcludedPages(): array
5355
$queryBuilder->createNamedParameter(1, Connection::PARAM_INT)
5456
)
5557
)
56-
->execute()
57-
->fetchAll();
58+
->executeQuery()
59+
->fetchFirstColumn();
5860

59-
return array_column($existingRows, 'uid');
60-
61+
return $excludedPages;
6162
}
6263

6364
public function executeUpdate(): bool
@@ -82,15 +83,15 @@ public function executeUpdate(): bool
8283
array_merge($existingPages, [0])
8384
)
8485
)
85-
->execute();
86+
->executeQuery();
8687

8788
return true;
8889
}
8990

9091
protected function doesRealurlFieldExist(): bool
9192
{
9293
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
93-
$columns = $conn->getSchemaManager()->listTableColumns('pages');
94+
$columns = $conn->getSchemaInformation()->introspectTable('pages')->getColumns();
9495
foreach ($columns as $column) {
9596
if (strtolower($column->getName()) === 'tx_realurl_exclude') {
9697
return true;

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"homepage": "https://github.com/b13/masi",
1414
"license": ["GPL-2.0-or-later"],
1515
"require": {
16-
"php": "^7.4 || ~8.0",
17-
"typo3/cms-core": "^10.4 || ^11.5 || ^12.0"
16+
"php": "^8.1",
17+
"typo3/cms-core": "^12.4 || ^13.0"
1818
},
1919
"replace": {
2020
"typo3-ter/masi": "self.version"

ext_emconf.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'version' => '2.0.3',
1212
'constraints' => [
1313
'depends' => [
14-
'typo3' => '10.4.0-12.99.99',
14+
'typo3' => '12.4.0-13.4.99',
1515
],
1616
],
1717
];

ext_localconf.php

-9
This file was deleted.

0 commit comments

Comments
 (0)