Skip to content

[TwigBridge] function twig_test_empty is deprecated in Twig 3.9 #52987

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
GromNaN opened this issue Dec 10, 2023 · 3 comments
Closed

[TwigBridge] function twig_test_empty is deprecated in Twig 3.9 #52987

GromNaN opened this issue Dec 10, 2023 · 3 comments

Comments

@GromNaN
Copy link
Member

GromNaN commented Dec 10, 2023

Symfony version(s) affected

5.4.31, 6.4.0, 7.0.0, 7.1

Description

The twig_* global functions are deprecated in Twig 3.9 twigphp/Twig#3883, and removed in Twig 4.0 twigphp/Twig#3937

The function twig_test_empty is used in Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode:

if (!twig_test_empty($label->getAttribute('value'))) {

$compiler->raw('(twig_test_empty($_label_ = ');

How to reproduce

composer create-project symfony/demo
composer require "twig/twig: 3.x-dev"

Go to https://localhost:8000/fr/admin/post/1/edit

Deprecation message:

Since twig/twig 3.9.0: Using the internal "twig_test_empty" function is deprecated.

Possible Solution

Duplicate the function as a static method in SearchAndRenderBlockNode.

Additional Context

No response

@xabbuh
Copy link
Member

xabbuh commented Dec 11, 2023

I'm on it

@TMWagner
Copy link

TMWagner commented Oct 24, 2024

@GromNaN
OK - so it is deprecated. Is there a replacement?

@GromNaN
Copy link
Member Author

GromNaN commented Oct 24, 2024

There is no replacement. This function is an implementation detail of the empty test, that's why the new CodeExtension::testEmpty() is flagged as @internal and should not be used. It can be modified or removed in any minor version.

You should write your own function.

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

4 participants