Merge branch '1.x' into 2.x

* 1.x:
  fixed batch filter clobbers array keys when fill parameter is used
  added preserveKeys support for the batch filter
  removed dead code
  fixed "embed" support when used from "template_from_string"
  fixed CS
This commit is contained in:
Fabien Potencier
2019-03-12 11:07:16 +01:00
9 changed files with 68 additions and 19 deletions
+12 -4
View File
@@ -299,7 +299,7 @@ class Environment
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '___'.$index);
}
/**
@@ -379,9 +379,17 @@ class Environment
*/
public function loadTemplate($name, $index = null)
{
$cls = $mainCls = $this->getTemplateClass($name);
return $this->loadClass($this->getTemplateClass($name), $name, $index);
}
/**
* @internal
*/
public function loadClass($cls, $name, $index = null)
{
$mainCls = $cls;
if (null !== $index) {
$cls .= '_'.$index;
$cls .= '___'.$index;
}
if (isset($this->loadedTemplates[$cls])) {
@@ -411,7 +419,7 @@ class Environment
}
if (!class_exists($cls, false)) {
throw new RuntimeError(sprintf('Failed to load Twig template "%s", index "%s": cache is corrupted.', $name, $index), -1, $source);
throw new RuntimeError(sprintf('Failed to load Twig template "%s", index "%s": cache might be corrupted.', $name, $index), -1, $source);
}
}
}