mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-20 14:36:57 +00:00
Merge branch '1.x'
* 1.x: bumped version to 1.22.4-DEV prepared the 1.22.3 release updated CHANGELOG updated CHANGELOG simplified logic and improve perf slightly Added a cache for extension freshness test added a note about using .. and | together fixed BC break by allowing null as the cache strategy fixed CS Check if cached file exists fixed CS
This commit is contained in:
@@ -13,8 +13,17 @@
|
||||
* improved the performance of the filesystem loader
|
||||
* removed features that were deprecated in 1.x
|
||||
|
||||
* 1.22.3 (2015-XX-XX)
|
||||
* 1.22.4 (2015-XX-XX)
|
||||
|
||||
* n/a
|
||||
|
||||
* 1.22.3 (2015-10-13)
|
||||
|
||||
* fixed regression when using null as a cache strategy
|
||||
* improved performance when checking template freshness
|
||||
* fixed warnings when loaded templates do not exist
|
||||
* fixed template class name generation to prevent possible collisions
|
||||
* fixed logic for custom escapers to call them even on integers and null values
|
||||
* changed template cache names to take into account the Twig C extension
|
||||
|
||||
* 1.22.2 (2015-09-22)
|
||||
|
||||
+18
-6
@@ -758,15 +758,27 @@ tests.
|
||||
Other Operators
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
The following operators are very useful but don't fit into any of the other
|
||||
categories:
|
||||
|
||||
* ``..``: Creates a sequence based on the operand before and after the
|
||||
operator (this is just syntactic sugar for the :doc:`range<functions/range>`
|
||||
function).
|
||||
The following operators don't fit into any of the other categories:
|
||||
|
||||
* ``|``: Applies a filter.
|
||||
|
||||
* ``..``: Creates a sequence based on the operand before and after the operator
|
||||
(this is just syntactic sugar for the :doc:`range<functions/range>` function):
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ 1..5 }}
|
||||
|
||||
{# equivalent to #}
|
||||
{{ range(1, 5) }}
|
||||
|
||||
Note that you must use parentheses when combining it with the filter operator
|
||||
due to the :ref:`operator precedence rules <twig-expressions>`:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
(1..5)|join(', ')
|
||||
|
||||
* ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello
|
||||
" ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
|
||||
John!``.
|
||||
|
||||
@@ -87,6 +87,10 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
*/
|
||||
public function getTimestamp($key)
|
||||
{
|
||||
if (!file_exists($key)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) @filemtime($key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class Twig_Environment
|
||||
private $filterCallbacks = array();
|
||||
private $staging;
|
||||
private $originalCache;
|
||||
private $lastModifiedExtension = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -238,6 +239,10 @@ class Twig_Environment
|
||||
} elseif (false === $cache) {
|
||||
$this->originalCache = $cache;
|
||||
$this->cache = new Twig_Cache_Null();
|
||||
} elseif (null === $cache) {
|
||||
@trigger_error('Using "null" as the cache strategy is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
$this->originalCache = false;
|
||||
$this->cache = new Twig_Cache_Null();
|
||||
} elseif ($cache instanceof Twig_CacheInterface) {
|
||||
$this->originalCache = $this->cache = $cache;
|
||||
} else {
|
||||
@@ -386,14 +391,7 @@ class Twig_Environment
|
||||
*/
|
||||
public function isTemplateFresh($name, $time)
|
||||
{
|
||||
foreach ($this->extensions as $extension) {
|
||||
$r = new ReflectionObject($extension);
|
||||
if (filemtime($r->getFileName()) > $time) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getLoader()->isFresh($name, $time);
|
||||
return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -665,6 +663,11 @@ class Twig_Environment
|
||||
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
||||
}
|
||||
|
||||
$r = new ReflectionObject($extension);
|
||||
if (($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
|
||||
$this->lastModifiedExtension = $extensionTime;
|
||||
}
|
||||
|
||||
$this->extensions[$extension->getName()] = $extension;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user