Skip to content

Commit

Permalink
[TASK] Create upgrade wizard for blogexample_pi1 (#99)
Browse files Browse the repository at this point in the history
* [BUGFIX] Prevent type errors if subtitle is not set

releases: main

* [TASK] Create upgrade wizard for blogexample_pi1

Had to remove rector from the composer.json as
typo3/cms-install depends on nikic/php-parser 5 while rector still depends on 4

releases: main
  • Loading branch information
linawolf authored May 2, 2024
1 parent 71fede2 commit 02ae059
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
59 changes: 59 additions & 0 deletions Classes/Upgrades/PluginUpgradeWizard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace T3docs\BlogExample\Upgrades;

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

#[UpgradeWizard('blogExample_pluginUpgradeWizard')]
final class PluginUpgradeWizard implements UpgradeWizardInterface
{
private const OLD_LIST_TYPE = 'blogexample_pi1';
private const NEW_LIST_TYPE = 'blogexample_bloglist';
public function __construct(
private readonly ConnectionPool $connectionPool,
) {}

public function getTitle(): string
{
return 'Rename outdated plugins';
}

public function getDescription(): string
{
return '';
}

public function executeUpdate(): bool
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
$result = $queryBuilder
->update('tt_content')
->where(
$queryBuilder->expr()->eq('list_type', $queryBuilder->createNamedParameter(self::OLD_LIST_TYPE)),
)
->set('list_type', self::NEW_LIST_TYPE)
->executeStatement();
return $result > 0;
}

public function updateNecessary(): bool
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
$count = $queryBuilder
->count('uid')
->from('tt_content')
->where(
$queryBuilder->expr()->eq('list_type', $queryBuilder->createNamedParameter(self::OLD_LIST_TYPE)),
)
->executeQuery()
->fetchOne();
return is_int($count) && $count > 0;
}

public function getPrerequisites(): array
{
return [];
}
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"typo3/cms-backend": "^13.1 || dev-main",
"typo3/cms-core": "^13.1 || dev-main",
"typo3/cms-extbase": "^13.1 || dev-main",
"typo3/cms-fluid": "^13.1 || dev-main"
"typo3/cms-fluid": "^13.1 || dev-main",
"typo3/cms-install": "^13.1"
},
"require-dev": {
"ergebnis/composer-normalize": "~2.42.0",
"friendsofphp/php-cs-fixer": "^3.52",
"phpstan/phpstan": "^1.10",
"ssch/typo3-rector": "^2.5"
"phpstan/phpstan": "^1.10"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down

0 comments on commit 02ae059

Please sign in to comment.