php - Symfony 2.7.4 Twig 错误

标签 php symfony

我刚刚从 Symfony 2.7.3 升级到 2.7.4。 升级后,在 2.7.3 下工作的表单现在抛出此错误

An exception has been thrown during the compilation of a template ("Notice:   Undefined variable: test")

模板中没有名为“test”的变量。

异常还显示此代码片段:

    if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
        $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
        if ($test->getAlternative()) {
            $message .= sprintf('. Use "%s" instead', $function->getAlternative());
        }
        $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);

此代码片段表明 twig 正在测试已弃用的函数,如果属实,Symfony 会反对 undefined variable $test。

有人遇到过这个错误或者可以提供如何解决的建议吗? 此错误是否是由表单中的其他内容间接引起的?

最佳答案

您应该升级到 Twig 1.21.2,请参阅 http://symfony.com/blog/twig-1-21-2-released

关于php - Symfony 2.7.4 Twig 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32470687/

相关文章:

php - 如何修复错误 : Socket_recv unable to read from socket 0 The operation completed successfully

php - 如何在 Twig View 中获取数组的键名

php - 添加类以在 Symfony FormBuilder 中选择选项

php - Laravel迁移: pivot table role_user doesn't exist

php - jQuery 对话框在更改时不显示 div

php - 无法使用 mysql_* API 建立连接

symfony - 如何让 Symfony 表单与 REST API 一起使用?

php - 通过关系发现了一个新实体 - 仅从形式

php - 如何在 TWIG 函数中获取当前模板名称

Symfony2 : How to enable autocompletion for annotations in PHPStorm?