omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
258 stars 115 forks source link

Twig deprecation - use AbstractExtension instead of Twig_Extension #94

Closed richardhooper closed 4 years ago

richardhooper commented 5 years ago

A recent change to Twig has resulted in a deprecation warning when using datatables-bundle:

Using the "Twig_Extension" class is deprecated since Twig version 2.7, use "Twig\Extension\AbstractExtension" instead.

The fix itself looks relatively simple - just extend AbstractExtension instead of Twig_Extension (in HEAD Twig_Extension is a straight subclass of AbstractExtension, no extra code at all). But there would potentially be a knock-on effect to datatables-bundle dependencies.

A bit of rummaging on Packagist etc gives me the following:

The deprecation was introduced in twig/twig on 2019-03-05; v2.7.0 was released 2019-03-12.

symfony/symfony starts requiring twig/twig ^2.9 instead of ^2.4.4 in v3.4.27, released 2019-04-17.

omines/datatables-bundle doesn't directly require twig/twig, but does support no lower than Symfony ^3.4

I'm not sure how old a version of twig/twig would be compatible with just extending AbstractExtension. It seems to have existed since 2017-05-24, but there's some namespacing stuff going on that I don't quite get.

curry684 commented 5 years ago

The change is indeed simple, will just have to bounce the versions up correctly to retain B/C.

PRs welcome.

curry684 commented 4 years ago

This was fixed as part of the Symfony 5.0 upgrades.

https://github.com/omines/datatables-bundle/blob/2a7ba3f5fb195bc2bc03234cf1f5d0a9631253ec/src/Twig/DataTablesExtension.php#L13-L23