Skip to content

Commit

Permalink
Do not try to generate fragments for generated fragments (see #2521)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aschempp committed Dec 7, 2020
1 parent e6c4b18 commit 77c79be
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -83,6 +83,14 @@ protected function registerFragments(ContainerBuilder $container, string $tag):
$command = $container->hasDefinition('contao.command.debug_fragments') ? $container->findDefinition('contao.command.debug_fragments') : null;

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

$definition = $container->findDefinition($reference);

$tags = $definition->getTag($tag);
Expand Down

0 comments on commit 77c79be

Please sign in to comment.