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

Infinite recursion loop in file loader when testing TYPO3 extension standalone #6712

Closed
simonschaufi opened this issue Sep 30, 2021 · 3 comments
Assignees
Labels

Comments

@simonschaufi
Copy link

simonschaufi commented Sep 30, 2021

Bug Report

Subject Details
Rector version 0.11.56

Following the best practices to setup an extension for development here: https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/Testing/ExtensionTesting.html#preparing-composer-json to make it ready for unit testing and executing composer install in the extension directory results in a new folder .Build where all the "vendor" stuff will be inside. The last step is to symlink the current directory into the .Build/public/typo3conf/ext/extension_name/ in order to have a standalone TYPO3 test installation within the .Build/public/ folder.

Now I tried to upgrade this extension with some TYPO3 rector rules witih:

$parameters->set(Option::PATHS, [
    __DIR__,
]);

and then the basic template from: https://github.com/sabbelasichon/typo3-rector/blob/main/docs/configuration_and_processing.md

and then I ran rector like this:

.Build/bin/rector process --xdebug --dry-run

which never showed the progress bar as it was trying to load all the files recursively and following the symlink forever even though I configured the following paths as skipped:

    $parameters->set(Option::SKIP, [
        NameImportingPostRector::class => [
            'ClassAliasMap.php',
            'ext_emconf.php',
            'ext_localconf.php',
            'ext_tables.php',
            __DIR__ . '/Configuration/AjaxRoutes.php',
            __DIR__ . '/Configuration/Backend/AjaxRoutes.php',
            __DIR__ . '/Configuration/Commands.php',
            __DIR__ . '/Configuration/ExpressionLanguage.php',
            __DIR__ . '/Configuration/Extbase/Persistence/Classes.php',
            __DIR__ . '/Configuration/RequestMiddlewares.php',
            __DIR__ . '/Configuration/TCA/*',
        ],
        __DIR__ . '/Configuration/ExtensionBuilder/*',
        __DIR__ . '/.github/*',
        __DIR__ . '/.idea/*',
        __DIR__ . '/.Build/*',  // <---------------- .Build folder excluded here!
        __DIR__ . '/Documentation/*',
        __DIR__ . '/Resources/*',
        __DIR__ . '/Tests/*',
    ]);

but when I debugged the whole thing, I noticed that they are actually NOT used directly for the symfony finder but afterwards.

Expected Behaviour

The root cause is in https://github.com/rectorphp/rector/blob/main/src/FileSystem/FilesFinder.php#L84 where the followLinks is explicitly set.

The expected behaviour is obviously that infinite recursion is detected and avoided but I don't know what is the best solution here. Removing the followLinks would fix my issue but maybe some other people need it?

@simonschaufi simonschaufi changed the title Infinite loop in file loader when testing TYPO3 extension standalone Infinite recursion loop in file loader when testing TYPO3 extension standalone Sep 30, 2021
@sabbelasichon
Copy link
Contributor

sabbelasichon commented Sep 30, 2021

Had the same issue lately for a phpstan related run. I solved it by whitelisting files and folders. So the . (dot) is not working here. I don´t know what will be the effect if we set the followLinks to false. Would vote against it and work with the whitelist approach.

@simonschaufi
Copy link
Author

@sabbelasichon could you provide a different init template for standalone extensions with this whitelist approach? I guess many people will stumble over this issue sooner or later...

@sabbelasichon
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants