升级 Twig 并升级到 Symfony 2.8.18 后在模板中找不到块

Block not found within template following upgrade of Twig and upgrade to Symfony 2.8.18

我刚刚从 Symfony 2.7 升级到 2.8.18,现在当我访问一个页面时出现以下错误,该页面的表单在升级之前可以正常工作。

Block "_appbundle_crmpicco_reserve_widget" on template "::base.html.twig" does not exist.

reserve.html.twig:

// this extends the top-level ::base.html.twig
{% extends "AppBundle:CRMPicco:base.html.twig" %} 
{% block _appbundle_crmpicco_reserve_widget %}
    {% spaceless %}
    {# Call the parent setup #}
    {{- parent() -}}

    {# Display the widget now #}
    {{ form_widget(form) }}
    <span class='validation-box glyphicon'></span>
    {% endspaceless %}
{%- endblock %}

作为我的一部分,Twig 也有明显的升级 composer update:

  - Removing twig/twig (v1.24.2)
  - Installing twig/twig (v2.2.0)
    Downloading: 100%      

模板继承在更新的版本中有变化吗?我在 Symfony upgrade docs.

中找不到任何内容

您的问题是块 _appbundle_crmpicco_reserve_widget 在父 AppBundle:CRMPicco:base.html.twig 模板中不存在。在 Twig 1.x 中,调用子模板中的 parent() 静默返回。这在 Twig 1.29 中已弃用,自 Twig 2.0 以来抛出异常。