symfony-bundle: Null SourceCollection error with update 0.6.2 and 0.7.0

I have a working installation or 0.6.1 but after an update to 0.7.0 my installation is broken. I tried 0.6.2 but experience the same error as on 0.7.0

The error I get is: Type error: Argument 2 passed to Translation\Extractor\Visitor\Twig\Worker::work() must be an instance of Translation\Extractor\Model\SourceCollection, null given, called in [...]/vendor/php-translation/extractor/src/Visitor/Twig/TwigVisitor.php on line 63

I’m not sure what exactly the problem is other than it seems the SourceCollection isn’t initialised before being used.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Thank you for all the investigation and research. I’ve finally manage to find the issue (based on the comments here).

See PR: https://github.com/php-translation/extractor/pull/115

I’m having the same issue. I use J-Mose/CommandSchedulerBundle, when accessing this bundles front via the ‘command-scheduler/list’ route, there are no problems. However when clicking the new button at their ‘command-scheduler/detail/new’ route, the php-translation/symfony-bundle throuws this very same error.

I can confirm this issue is present in 0.6.2 and 0.7.0 of this bundle, but not in 0.6.1. I’m also running Symfony 3.4.8

This is fixed if you update to 1.6.0 of php-translation/extractor.

https://github.com/php-translation/extractor/releases/tag/1.6.0

I’ve done some investigating, and the issue may be from the php-translation/extractor package, when calling Translation\Extractor\Visitor\Twig\TwigVisitor.php on line 62.

$this->collection is null there, as well as $this->file. These variables don’t get initialized in the TwigVisitor constructor, but get initialized in the parent class, BaseVisitor in the init() function. However this function appears to not be called anywhere, hence $collection and $file are null.