Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
diam opened this issue Sep 10, 2024 · 4 comments
Closed

Comments

@diam
Copy link

diam commented Sep 10, 2024

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

@derrabus
Copy link
Member

This has been solved by #58207 already.

@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
@xVinniVx
Copy link

I have the same issue after updating Symfony to 7.1.4.

I'm using:

-symfony/twig-bundle - 7.1.1
- twig/extra-bundle - 3.13.0
- twig/twig - 3.14.0

When I'm on any form, there is Application DEPREC INFO:
[Application] Sep 12 21:01:13 |INFO | DEPREC User Deprecated: Since twig/twig 3.14: The "Twig\Environment::mergeGlobals" method is deprecated.

@derrabus
Copy link
Member

… and my answer also applies to you.

@xabbuh
Copy link
Member

xabbuh commented Sep 21, 2024

FYI, 7.1.5 (as well as patches for 5.4 and 6.4) have been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants