Reputation: 664
I'm using Symfony 2.3 and have deprecation warnings in my profiler related to Twig. Such as:
DEPRECATION - Using "replace" with character by character replacement is deprecated
and will be removed in Twig 2.0
And the |replace
tag seems to be still part of the Twig documentation, so I am a little confused on how to deal with this Warning.
Also, I get similar Deprecation Warnings from third-party bundles that I use.
Upvotes: 5
Views: 2260
Reputation: 1805
You need to change the way you pass the arguments to replace function in twig :
{{str | replace ('a','b') }}
{{str | replace ({'a': 'b'}) }}
Before it was two arguments, now it's an array.
You can check in the code source that it's not the replace twig_replace_filter function wich is deprecated but only one way of calling it : https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Extension/Core.php#L534
Note that the twig doc display the right example : http://twig.sensiolabs.org/doc/filters/replace.html
Upvotes: 8
Reputation: 1410
In fact, the only way to fix it is to replace all your deprecated functions.
But this should cause troubles only if you upgrade your twig bundle by :
Composer update if you have a tag in your composer.json
which is not a version (like "twig/extensions": "1.*",
)
If you upgrade your symfony with a version which requires twig 2.x
In fact, you're project won't be affected by this warning if you stay on this version.
Upvotes: 0