From: Fabien Potencier Date: Tue, 17 Jan 2012 06:17:24 +0000 (+0100) Subject: merged branch Seldaek/globals_fix (PR #600) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3fbe8d8c469d8db70e6232f8c740130e5d07f4a1;p=web%2Fkonrad%2Ftwig.git merged branch Seldaek/globals_fix (PR #600) Commits ------- 43ebae1 Reset parsers, visitors, filters, tests, functions when a new one or new extension is added 3db62da Reset globals when a new global is added Discussion ---------- Reset globals when a new global is added if getGlobals() is called before adding a new global, it is never taken into account --------------------------------------------------------------------------- by fabpot at 2012-01-16T14:27:02Z Is it related to #594? --------------------------------------------------------------------------- by Seldaek at 2012-01-16T14:30:08Z Seems like it yes. It means that reading globals + writing + reading again will call getGlobals on all extensions again though. A slight improvement would be to cache the extension globals in another var that can be re-applied at once over the staged globals. The fastest would be to just set directly in ->globals if it's already initalized, but that means addGlobal can override extension globals. Not sure if that is a problem, but it creates a somewhat non-deterministic factor. I can adjust as required. --------------------------------------------------------------------------- by stof at 2012-01-16T14:45:49Z @Seldaek shouldn't the same be done for other methods (filters, functions, tags, tests and operators) ? --------------------------------------------------------------------------- by Seldaek at 2012-01-16T14:53:28Z Indeed, I was just focused on my crazy issue here :) Once @fabpot decides which way he prefers I can apply it to everything. --------------------------------------------------------------------------- by fabpot at 2012-01-16T21:05:19Z +1 for the the approach in this PR. @Seldaek: Can you apply it to everything else as well? Thanks. --------------------------------------------------------------------------- by Seldaek at 2012-01-17T00:54:08Z Done, also did it for adding and removing extensions since they potentially override stuff. --- 3fbe8d8c469d8db70e6232f8c740130e5d07f4a1