Skip to content

Commit

Permalink
[Twig] made a small optimization to avoid problems with XDebug when r…
Browse files Browse the repository at this point in the history
…endering forms with deep nested collections
  • Loading branch information
fabpot committed Jul 16, 2011
1 parent e3a14c8 commit 634131b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Symfony/Bridge/Twig/Extension/FormExtension.php
Expand Up @@ -248,7 +248,10 @@ protected function render(FormView $view, $section, array $variables = array())

$this->varStack[$rendering]['typeIndex'] = $typeIndex;

$html = $this->template->renderBlock($types[$typeIndex], $this->varStack[$rendering]['variables'], $blocks);
// we do not call renderBlock here to avoid too many nested level calls (XDebug limits the level to 100 by default)
ob_start();
$this->template->displayBlock($types[$typeIndex], $this->varStack[$rendering]['variables'], $blocks);
$html = ob_get_clean();

if ($mainTemplate) {
$view->setRendered();
Expand Down

2 comments on commit 634131b

@webmozart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that this is meant to remove one method call from the stack, but not more?

@stof
Copy link
Member

@stof stof commented on 634131b Apr 12, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bschussek the form extension is called recursively when rendering a form as it is a tree structure. So it removes one method per call to the rendering function (which is called many times when rendering a formà

Please sign in to comment.