sabbelasichon / typo3-rector

Rector for TYPO3
MIT License
215 stars 60 forks source link

Title: Issue with `rector` Overwriting Custom Overrides in TCA Configuration After Update from 11 to 12 LTS #4225

Closed misterboe closed 2 months ago

misterboe commented 2 months ago

Hello,

I recently updated my TYPO3 project from version 11 to 12 LTS and encountered an issue when running rector version 2.4 as part of the update process. My project includes a custom extension created with the ExtensionBuilder. To extend its functionality, I have modified files in Configuration/TCA/Overrides.

The specific file paths affected are:

For example, I had the following configuration in my Overrides file:

$GLOBALS['TCA']['tx_[extensionName]_domain_model_[modelName]']['ctrl']['label_alt'] = 'locations';

However, after running rector, the Overrides file was completely overwritten with this content:

$GLOBALS['TCA']['tx_[extensionName]_domain_model_[modelName]']['ctrl']['security']['ignorePageTypeRestriction'] = true;

It appears that rector does not respect the existing content within the Overrides file.

Here is my rector config for reference:

return RectorConfig::configure()
    ->withConfiguredRule(ExtEmConfRector::class, [
        ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => []
    ])
    ->withPaths([
        __DIR__ . '/vendor/[vendorName]/site-package',
        __DIR__ . '/vendor/[vendorName]/[extensionName]',
    ])
    ->withPhpSets(
        true
    )
    ->withSets([
        Typo3LevelSetList::UP_TO_TYPO3_12,
        SetList::CODING_STYLE,
        SetList::CODE_QUALITY,
        SetList::NAMING,
        SetList::DEAD_CODE,
    ])
    ->withPHPStanConfigs([
        Typo3Option::PHPSTAN_FOR_RECTOR_PATH
    ])
    ->withPhpVersion(PhpVersion::PHP_82)
    ->withRules([
        ConvertImplicitVariablesToExplicitGlobalsRector::class,
    ])
    ->withSkip([
        __DIR__ . '/**/Configuration/ExtensionBuilder/*',
    ])
;
simonschaufi commented 2 months ago

@sabbelasichon In this case the rule should extend the line to an existing file instead of overwriting the whole file. I would just append the line at EOF if file exists.

sabbelasichon commented 2 months ago

That's what i would expect. Not good. Have to look at Flysystem

sabbelasichon commented 2 months ago

@misterboe Good catch. My bad. Could you test the new release 2.4.1

misterboe commented 2 months ago

@sabbelasichon Works now - Thanks for the quick fix