Skip to content

Commit

Permalink
feat: TYPO3 13.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanowak committed Nov 9, 2024
1 parent 2c2a2eb commit e86a5cc
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 176 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/apply-coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
tools: composer

- name: 'Get Composer Cache Directory'
Expand All @@ -26,7 +26,7 @@ jobs:
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Cache Composer Dependencies'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer
Expand All @@ -35,9 +35,9 @@ jobs:
shell: bash
run: composer install --no-interaction

- name: 'Rector PHP Code'
shell: bash
run: composer rector-fix
# - name: 'Rector PHP Code'
# shell: bash
# run: composer rector-fix

- name: 'Lint PHP Code'
shell: bash
Expand All @@ -52,8 +52,7 @@ jobs:
run: composer test-functional

- name: 'Create pull-request'
id: cpr
uses: peter-evans/[email protected]
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[automated] Apply Coding Standard"
Expand All @@ -62,9 +61,3 @@ jobs:
title: '[automated] Apply Coding Standard'
labels: 'automated'
delete-branch: true

- name: 'Enable Pull Request Merge when ready'
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ permissions:
jobs:
test:
runs-on: ubuntu-latest
name: TYPO3 v12.4 tests on PHP ${{ matrix.php }}
name: TYPO3 v13.4 tests on PHP ${{ matrix.php }}

strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3 ]
php: [ 8.3 ]

steps:
- name: 'Checkout code'
Expand All @@ -46,7 +46,7 @@ jobs:
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Cache Composer Dependencies'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php${{ matrix.php }}
Expand All @@ -72,7 +72,7 @@ jobs:
run: .Build/bin/phpcov merge --html .Build/artifacts/coverage/merged --clover .Build/artifacts/coverage/clover.xml .Build/artifacts/coverage/

- name: 'Generate code coverage summary report'
uses: saschanowak/CloverCodeCoverageSummary@0.4.0
uses: saschanowak/CloverCodeCoverageSummary@1.1.0
with:
filename: .Build/artifacts/coverage/clover.xml

Expand Down
8 changes: 4 additions & 4 deletions Classes/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ protected function configure(): void
->addArgument('package', InputArgument::OPTIONAL, 'Name of the package', '');
}

public function execute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$packages = array_filter(
$this->packageManager->getAvailablePackages(),
fn (PackageInterface $package) => !$package->getPackageMetaData()
fn (PackageInterface $package): bool => !$package->getPackageMetaData()
->isFrameworkType()
);
ksort($packages);
Expand Down Expand Up @@ -84,13 +84,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
ucfirst($this->doctrineService->getDatabasePlatformName()),
basename($migrationClassPathAndFilename)
);
GeneralUtility::mkdir_deep(dirname((string) $targetPathAndFilename));
GeneralUtility::mkdir_deep(dirname($targetPathAndFilename));
rename($migrationClassPathAndFilename, $targetPathAndFilename);

$output->writeln(
sprintf('The migration was moved to: <comment>%s</comment>', substr(
realpath($targetPathAndFilename),
strlen((string) Environment::getProjectPath())
strlen(Environment::getProjectPath())
))
);
$output->writeln('- Review and adjust the generated migration.');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure(): void
->addOption('dryRun', null, InputOption::VALUE_NONE, 'Whether to do a dry run or not');
}

public function execute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$result = $this->doctrineService->executeMigrations(
version: $this->normalizeVersion($input->getArgument('version')),
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/MigrationExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure(): void
->addOption('dryRun', null, InputOption::VALUE_NONE, 'Whether to do a dry run or not');
}

public function execute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$result = $this->doctrineService->executeMigration(
version: $this->normalizeVersion($input->getArgument('version')),
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/MigrationVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function configure(): void
->addOption('delete', null, InputOption::VALUE_NONE, 'The migration to mark as not migrated');
}

public function execute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('add') === false && $input->getOption('delete') === false) {
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure(): void
);
}

public function execute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln($this->doctrineService->getFormattedMigrationStatus($input->getOption('showMigrations')));

Expand Down
10 changes: 8 additions & 2 deletions Classes/Service/DependencyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Netlogix\Migrations\Service;

use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\DependencyFactory as DoctrineDependencyFactory;
Expand Down Expand Up @@ -40,13 +43,16 @@ public function createFromConnection(Connection $connection, BufferedOutput $log
$connectionLoader = new ExistingConnection($connection);
$logger = new ConsoleLogger($logMessages);

$databasePlatformName = ucfirst((string) $connection->getDatabasePlatform()->getName());
$dependencyFactory = DoctrineDependencyFactory::fromConnection($configurationLoader, $connectionLoader);
$dependencyFactory->setService(
MigrationFinderInterface::class,
new MigrationFinder(
packageManager: GeneralUtility::makeInstance(PackageManager::class),
databasePlatformName: $databasePlatformName,
databasePlatformName: match (true) {
$connection->getDatabasePlatform() instanceof AbstractMySQLPlatform => 'Mysql',
$connection->getDatabasePlatform() instanceof PostgreSQLPlatform => 'Postgresql',
$connection->getDatabasePlatform() instanceof SQLitePlatform => 'Sqlite',
}
)
);
$dependencyFactory->setService(LoggerInterface::class, $logger);
Expand Down
16 changes: 11 additions & 5 deletions Classes/Service/DoctrineService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Netlogix\Migrations\Service;

use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\Migrations\DependencyFactory as DoctrineDependencyFactory;
use Doctrine\Migrations\Exception\MigrationClassNotFound;
use Doctrine\Migrations\Exception\NoMigrationsFoundWithCriteria;
Expand Down Expand Up @@ -83,7 +86,7 @@ public function executeMigrations(
string $outputPathAndFilename = null,
mixed $dryRun = false,
bool $quiet = false
) {
): string {
$migrationRepository = $this->dependencyFactory->getMigrationRepository();
if (count($migrationRepository->getMigrations()) === 0) {
return sprintf('The version "%s" can\'t be reached, there are no registered migrations.', $version);
Expand Down Expand Up @@ -230,9 +233,12 @@ public function generateMigration(): string

public function getDatabasePlatformName(): string
{
return $this->dependencyFactory->getConnection()
->getDatabasePlatform()
->getName();
$platform = $this->connection->getDatabasePlatform();
return match (true) {
$platform instanceof AbstractMySQLPlatform => 'Mysql',
$platform instanceof PostgreSQLPlatform => 'Postgresql',
$platform instanceof SQLitePlatform => 'Sqlite',
};
}

private function getSortedVersions(
Expand Down Expand Up @@ -323,7 +329,7 @@ private function mark(
$marked = true;
}

if ($marked === true) {
if ($marked) {
return;
}

Expand Down
6 changes: 1 addition & 5 deletions Classes/Service/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ public static function concatenatePaths(string ...$paths): string
$resultingPath = '';
foreach ($paths as $index => $path) {
$path = GeneralUtility::fixWindowsFilePath($path);
if ($index === 0) {
$path = rtrim($path, '/');
} else {
$path = trim($path, '/');
}
$path = $index === 0 ? rtrim($path, '/') : trim($path, '/');
if ($path !== '') {
$resultingPath .= $path . '/';
}
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;

return function (ContainerConfigurator $containerConfigurator) {
return function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services()
->defaults()
->autowire()
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
"type": "typo3-cms-extension",
"license": "MIT",
"require": {
"php": "^8.1",
"typo3/cms-core": "^12.4",
"doctrine/migrations": "^3.7"
"php": "^8.3",
"typo3/cms-core": "^12.4 | ^13.4",
"doctrine/migrations": "^3.8"
},
"require-dev": {
"ext-sqlite3": "*",
"ssch/typo3-rector": "^1.5",
"typo3/testing-framework": "^8.0",
"phpunit/phpcov": "^9.0",
"typo3/testing-framework": "^8.0 | ^9.0",
"phpunit/phpcov": "^9.0 | ^10.0",
"netlogix/coding-guidelines-php": "^1.0"
},
"autoload": {
Expand Down
7 changes: 7 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE `sys_doctrine_migrationstatus` (
version varchar(255) NOT NULL,
executed_at datetime,
execution_time integer,

PRIMARY KEY (version)
) ENGINE=InnoDB;
Loading

0 comments on commit e86a5cc

Please sign in to comment.