Skip to content

Commit 77c79be

Browse files
authored
Do not try to generate fragments for generated fragments (see contao#2521)
Description ----------- If a fragment has multiple methods with different fragment type (e.g. a content element and a front end module), the first RegisterFragmentsPass creates a child definition that inherits all tags from the original. On the next run, the RegisterFragmentsPass would pick up the child definition and try to create duplicate fragments. Commits ------- cc5d72c Do not try to generate fragments for generated fragments a0b92bb CS 4b8bc8f Merge branch '4.9' into bugfix/fragment-children
1 parent e6c4b18 commit 77c79be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core-bundle/src/DependencyInjection/Compiler/RegisterFragmentsPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ protected function registerFragments(ContainerBuilder $container, string $tag):
8383
$command = $container->hasDefinition('contao.command.debug_fragments') ? $container->findDefinition('contao.command.debug_fragments') : null;
8484

8585
foreach ($this->findAndSortTaggedServices($tag, $container) as $reference) {
86+
// If a controller has multiple methods for different fragment types (e.g. a content
87+
// element and a front end module), the first pass creates a child definition that
88+
// inherits all tags from the original. On the next run, the pass would pick up the
89+
// child definition and try to create duplicate fragments.
90+
if (0 === strpos((string) $reference, 'contao.fragment._')) {
91+
continue;
92+
}
93+
8694
$definition = $container->findDefinition($reference);
8795

8896
$tags = $definition->getTag($tag);

0 commit comments

Comments
 (0)