mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fix generating template name in createTemplate() method
Before this change the name for the template was generated randomly based on uniqid(mt_rand()). It generated new file whenever the template was loaded as string using the `template_from_string` even the template was the same. The generated file wasn't used anymore. Now the cache file is generated by the content of template so using the `template_from_string` is faster and doesn't pollute the cache folder with unneeded files.
This commit is contained in:
@@ -489,7 +489,7 @@ class Twig_Environment
|
|||||||
*/
|
*/
|
||||||
public function createTemplate($template)
|
public function createTemplate($template)
|
||||||
{
|
{
|
||||||
$name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
|
$name = sprintf('__string_template__%s', hash('sha256', $template, false));
|
||||||
|
|
||||||
$loader = new Twig_Loader_Chain(array(
|
$loader = new Twig_Loader_Chain(array(
|
||||||
new Twig_Loader_Array(array($name => $template)),
|
new Twig_Loader_Array(array($name => $template)),
|
||||||
|
|||||||
Reference in New Issue
Block a user