Merge branch '1.x' into 2.x

* 1.x:
  updated CHANGELOG
  Deprecate usage of undefined blocks
  deprecated support for mbstring.func_overload != 0
  bumped version to 1.28.3-DEV
  prepared the 1.28.2 release
This commit is contained in:
Fabien Potencier
2016-12-05 09:57:28 +01:00
7 changed files with 34 additions and 18 deletions
+6 -1
View File
@@ -17,7 +17,12 @@
* improved the performance of the filesystem loader
* removed features that were deprecated in 1.x
* 1.28.2 (2016-XX-XX)
* 1.29.0 (2016-XX-XX)
* deprecated silent display of undefined blocks
* deprecated support for mbstring.func_overload != 0
* 1.28.2 (2016-11-23)
* fixed precedence between getFoo() and isFoo() in Twig_Template::getAttribute()
* improved a deprecation message
+2
View File
@@ -184,6 +184,8 @@ class Twig_Compiler
// mb_substr_count() replaces substr_count()
// but they have different signatures!
if (((int) ini_get('mbstring.func_overload')) & 2) {
@trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
// this is much slower than the "right" version
$this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
} else {
-11
View File
@@ -74,13 +74,6 @@ class Twig_Lexer
public function tokenize(\Twig_Source $source)
{
if (((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
} else {
$mbEncoding = null;
}
$this->code = str_replace(array("\r\n", "\r"), "\n", $source->getCode());
$this->name = $source->getName();
$this->cursor = 0;
@@ -129,10 +122,6 @@ class Twig_Lexer
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->name);
}
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
return new Twig_TokenStream($this->tokens, $source);
}
+9 -5
View File
@@ -170,12 +170,16 @@ abstract class Twig_Template
$block = null;
}
if (null !== $template) {
// avoid RCEs when sandbox is enabled
if (!$template instanceof self) {
throw new LogicException('A block must be a method on a Twig_Template instance.');
}
// avoid RCEs when sandbox is enabled
if (null !== $template && !$template instanceof self) {
throw new LogicException('A block must be a method on a Twig_Template instance.');
}
if (!$this->hasBlock($name, $context, $blocks)) {
@trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0.', $name, $this->getTemplateName()), E_USER_DEPRECATED);
}
if (null !== $template) {
try {
$template->$block($context, $blocks);
} catch (Twig_Error $e) {
@@ -12,7 +12,7 @@
{% block list %}<ul>{{ block('children') }}</ul>{% endblock %}
{% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %}
{% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %}
{% block label %}{{ item }}{{ block('unknown') }}{% endblock %}
{% block label %}{{ item }}{% endblock %}
--TEMPLATE(base.twig)--
{{ block('list') }}
--DATA--
@@ -0,0 +1,12 @@
--TEST--
"block" function with undefined block
--TEMPLATE--
{% extends "base.twig" %}
{% block foo %}{{ parent() }}{{ block('unknown') }}{{ block('bar') }}{% endblock %}
--TEMPLATE(base.twig)--
{% block foo %}Foo{% endblock %}
{% block bar %}Bar{% endblock %}
--DATA--
return array()
--EXPECT--
FooBarBar
+4
View File
@@ -431,6 +431,10 @@ class Twig_TemplateTest extends Twig_Template
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
}
}
public function block_name($context, array $blocks = array())
{
}
}
class Twig_TemplateArrayAccessObject implements ArrayAccess