Skip to content

Since twig/twig 3.14: "Twig\Environment::mergeGlobals" method is deprecated #58219

Closed as not planned
@diam

Description

@diam

Symfony version(s) affected

7.1.4

Description

I just do a composer update and pass twig/twig to 3.14.0 (from 3.13.0 but not sure).

Displaying a new form raise the following deprecated:

Since twig/twig 3.14: The "Twig\Environment::mergeGlobals" method is deprecated 

I've no call to mergeGlobals in my code but found it il the following files:

./vendor/symfony/twig-bridge/Form/TwigRendererEngine.php:
        $context = $this->environment->mergeGlobals($variables);
./vendor/symfony/twig-bridge/Form/TwigRendererEngine.php:
        $context = $this->environment->mergeGlobals([]);
./vendor/twig/twig/CHANGELOG:
        * Deprecate `Environment::mergeGlobals()`
./vendor/twig/twig/src/Environment.php:
         public function mergeGlobals(array $context): array

I have no full example, but perhaps this extract could help

My form:

{{ form_start(form, {'attr': {'class': 'madi-form', 'novalidate': 'novalidate'}}) }}
...
{{ form_end(form) }}

My controller (make use of the form with no Form option):

        $form = $this->createForm(ActuType::class, $actu);

How to reproduce

Not sure of that because another form template with the same option does'n t raise this deprecated:

{{ form_start(form, {'attr': {'class': 'madi-form', 'novalidate': 'novalidate'}}) }}

Possible Solution

Replace the use of the mergeGlobals deprecated Twig method in the twig-bridge package? ;-)

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions