noiselabs / SmartyBundle

Smarty3 template engine bundle for Symfony
http://smartybundle.readthedocs.io/
GNU Lesser General Public License v3.0
51 stars 36 forks source link

fix problem with "plugin tag are already registered" debug messages #51

Closed naucon closed 8 years ago

naucon commented 8 years ago

thank you for your hard work on this great bundle.

I noticed a lot of "plugin tag already registered" debug messages on a project of mine. The project uses the Symfony AppCache and a lot of ESI's. With every ESI render() a block of this debug messages were logged.

[2016-03-18 18:43:33] SmartyBundle.DEBUG: SmartyException caught: Plugin tag "path" already registered.
[2016-03-18 18:43:33] SmartyBundle.DEBUG: SmartyException caught: Plugin tag "path" already registered.
[2016-03-18 18:43:33] SmartyBundle.DEBUG: SmartyException caught: Plugin tag "url" already registered.
[2016-03-18 18:43:33] SmartyBundle.DEBUG: SmartyException caught: Plugin tag "url" already registered.

The debug messages are caused because the method registerPlugins() is called on the method render(). registerPlugins() registers the plugins on the Smarty instance regardless if it is already registered.

My solution is to track which plugins are already registered and skip those that are being already registered. That allows to add plugins between two or more render() calls.

I would appreciate if you could merge my pull request.

vitorbrandao commented 8 years ago

Thanks for your contribution @naucon. Added a comment to the PR but happy to merge as is.