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

Fatal error: Uncaught TypeError: trim() #3453

Closed
ste101 opened this issue Aug 19, 2023 · 2 comments · Fixed by #3454
Closed

Fatal error: Uncaught TypeError: trim() #3453

ste101 opened this issue Aug 19, 2023 · 2 comments · Fixed by #3454
Labels

Comments

@ste101
Copy link

ste101 commented Aug 19, 2023

Bug Report

I tried to use rector on EXT:imagecycle (https://extensions.typo3.org/extension/imagecycle) and got this error:

/files/.mwsoftware/composer/vendor/bin/rector process typo3conf/ext/imagecycle/ --autoload-file=autoload.php
  56/110 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░]  50%Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, null given in /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/Conditions/GlobalStringConditionMatcher.php:37
Stack trace:
#0 /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/Conditions/GlobalStringConditionMatcher.php(37): trim(NULL)
#1 /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/Rector/v9/v4/OldConditionToExpressionLanguageTypoScriptRector.php(73): Ssch\TYPO3Rector\FileProcessor\TypoScript\Conditions\GlobalStringConditionMatcher->change('...')
#2 /files/.mwsoftware/composer/vendor/helmich/typo3-typoscript-parser/src/Parser/Traverser/AggregatingVisitor.php(45): Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v4\OldConditionToExpressionLanguageTypoScriptRector->enterNode(Object(Helmich\TypoScriptParser\Parser\AST\ConditionalStatement))
#3 /files/.mwsoftware/composer/vendor/helmich/typo3-typoscript-parser/src/Parser/Traverser/Traverser.php(57): Helmich\TypoScriptParser\Parser\Traverser\AggregatingVisitor->enterNode(Object(Helmich\TypoScriptParser\Parser\AST\ConditionalStatement))
#4 /files/.mwsoftware/composer/vendor/helmich/typo3-typoscript-parser/src/Parser/Traverser/Traverser.php(46): Helmich\TypoScriptParser\Parser\Traverser\Traverser->walkRecursive(Array)
#5 /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/TypoScriptFileProcessor.php(201): Helmich\TypoScriptParser\Parser\Traverser\Traverser->walk()
#6 /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/TypoScriptFileProcessor.php(159): Ssch\TYPO3Rector\FileProcessor\TypoScript\TypoScriptFileProcessor->processFile(Object(Rector\Core\ValueObject\Application\File))
#7 /files/.mwsoftware/composer/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(169): Ssch\TYPO3Rector\FileProcessor\TypoScript\TypoScriptFileProcessor->process(Object(Rector\Core\ValueObject\Application\File), Object(Rector\Core\ValueObject\Configuration))
#8 /files/.mwsoftware/composer/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(139): Rector\Core\Application\ApplicationFileProcessor->processFiles(Array, Object(Rector\Core\ValueObject\Configuration))
#9 /files/.mwsoftware/composer/vendor/rector/rector/src/Console/Command/ProcessCommand.php(120): Rector\Core\Application\ApplicationFileProcessor->run(Object(Rector\Core\ValueObject\Configuration), Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput))
#10 /files/.mwsoftware/composer/vendor/rector/rector/vendor/symfony/console/Command/Command.php(325): Rector\Core\Console\Command\ProcessCommand->execute(Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202306\Symfony\Component\Console\Output\ConsoleOutput))
#11 /files/.mwsoftware/composer/vendor/rector/rector/vendor/symfony/console/Application.php(944): RectorPrefix202306\Symfony\Component\Console\Command\Command->run(Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202306\Symfony\Component\Console\Output\ConsoleOutput))
#12 /files/.mwsoftware/composer/vendor/rector/rector/vendor/symfony/console/Application.php(326): RectorPrefix202306\Symfony\Component\Console\Application->doRunCommand(Object(Rector\Core\Console\Command\ProcessCommand), Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202306\Symfony\Component\Console\Output\ConsoleOutput))
#13 /files/.mwsoftware/composer/vendor/rector/rector/src/Console/ConsoleApplication.php(49): RectorPrefix202306\Symfony\Component\Console\Application->doRun(Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202306\Symfony\Component\Console\Output\ConsoleOutput))
#14 /files/.mwsoftware/composer/vendor/rector/rector/vendor/symfony/console/Application.php(212): Rector\Core\Console\ConsoleApplication->doRun(Object(RectorPrefix202306\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202306\Symfony\Component\Console\Output\ConsoleOutput))
#15 /files/.mwsoftware/composer/vendor/rector/rector/bin/rector.php(132): RectorPrefix202306\Symfony\Component\Console\Application->run()
#16 /files/.mwsoftware/composer/vendor/rector/rector/bin/rector(5): require_once('...')
#17 /files/.mwsoftware/composer/vendor/bin/rector(117): include('...')
#18 {main}
  thrown in /files/.mwsoftware/composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/Conditions/GlobalStringConditionMatcher.php on line 37
@ste101 ste101 added the Bug label Aug 19, 2023
@ste101
Copy link
Author

ste101 commented Aug 20, 2023

composer/vendor/ssch/typo3-rector/src/FileProcessor/TypoScript/Rector/v9/v4/OldConditionToExpressionLanguageTypoScriptRector.php finds condition where no condition is:
https://github.com/franzholz/imagecycle/blob/master/Configuration/TCA/Overrides/tt_news.php

I change line 37-40 to

            $type = trim($matches['type'] ?? '');
            $property = trim($matches['property'] ?? '');
            $operator = trim($matches['operator'] ?? '');
            $value = trim($matches['value'] ?? '');

Error is gone but I don't think this is the correct solution

@sabbelasichon
Copy link
Owner

@ste101 Thanks. I guess the reason is this line here: https://github.com/franzholz/imagecycle/blob/master/Configuration/TypoScript/PluginSetup/tt_news/nivoslider/setup.txt#L1

Rector cannot rewrite this condition, because there is no equivalent for the Symfony Expression Language.

I have fixed the error in the latest release.

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

Successfully merging a pull request may close this issue.

2 participants