mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 11:13:27 +02:00
Update Twig from 1.35.0 to 1.42.4 (PHP 5.5 is now required!)
This fixes some errors on PHP 7.4 and contains even more fixes Also bumped PHP version to 5.5 as Twig requires it.
This commit is contained in:
60
system/libs/Twig/Cache/CacheInterface.php
Normal file
60
system/libs/Twig/Cache/CacheInterface.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig\Cache;
|
||||
|
||||
/**
|
||||
* Interface implemented by cache classes.
|
||||
*
|
||||
* It is highly recommended to always store templates on the filesystem to
|
||||
* benefit from the PHP opcode cache. This interface is mostly useful if you
|
||||
* need to implement a custom strategy for storing templates on the filesystem.
|
||||
*
|
||||
* @author Andrew Tch <andrew@noop.lv>
|
||||
*/
|
||||
interface CacheInterface
|
||||
{
|
||||
/**
|
||||
* Generates a cache key for the given template class name.
|
||||
*
|
||||
* @param string $name The template name
|
||||
* @param string $className The template class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateKey($name, $className);
|
||||
|
||||
/**
|
||||
* Writes the compiled template to cache.
|
||||
*
|
||||
* @param string $key The cache key
|
||||
* @param string $content The template representation as a PHP class
|
||||
*/
|
||||
public function write($key, $content);
|
||||
|
||||
/**
|
||||
* Loads a template from the cache.
|
||||
*
|
||||
* @param string $key The cache key
|
||||
*/
|
||||
public function load($key);
|
||||
|
||||
/**
|
||||
* Returns the modification timestamp of a key.
|
||||
*
|
||||
* @param string $key The cache key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimestamp($key);
|
||||
}
|
||||
|
||||
class_alias('Twig\Cache\CacheInterface', 'Twig_CacheInterface');
|
@@ -9,12 +9,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig\Cache;
|
||||
|
||||
/**
|
||||
* Implements a cache on the filesystem.
|
||||
*
|
||||
* @author Andrew Tch <andrew@noop.lv>
|
||||
*/
|
||||
class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
class FilesystemCache implements CacheInterface
|
||||
{
|
||||
const FORCE_BYTECODE_INVALIDATION = 1;
|
||||
|
||||
@@ -22,8 +24,8 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* @param $directory string The root cache directory
|
||||
* @param $options int A set of options
|
||||
* @param string $directory The root cache directory
|
||||
* @param int $options A set of options
|
||||
*/
|
||||
public function __construct($directory, $options = 0)
|
||||
{
|
||||
@@ -47,18 +49,16 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
|
||||
public function write($key, $content)
|
||||
{
|
||||
$dir = dirname($key);
|
||||
$dir = \dirname($key);
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
clearstatcache(true, $dir);
|
||||
}
|
||||
clearstatcache(true, $dir);
|
||||
if (!is_dir($dir)) {
|
||||
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
|
||||
throw new \RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
|
||||
}
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
|
||||
throw new \RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
|
||||
}
|
||||
|
||||
$tmpFile = tempnam($dir, basename($key));
|
||||
@@ -67,9 +67,9 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
|
||||
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
|
||||
// Compile cached file into bytecode cache
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($key, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
@opcache_invalidate($key, true);
|
||||
} elseif (\function_exists('apc_compile_file')) {
|
||||
apc_compile_file($key);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $key));
|
||||
}
|
||||
|
||||
public function getTimestamp($key)
|
||||
@@ -90,4 +90,4 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('Twig_Cache_Filesystem', 'Twig\Cache\FilesystemCache', false);
|
||||
class_alias('Twig\Cache\FilesystemCache', 'Twig_Cache_Filesystem');
|
@@ -9,6 +9,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig\Cache;
|
||||
|
||||
/**
|
||||
* Implements a no-cache strategy.
|
||||
*
|
||||
@@ -16,7 +18,7 @@
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Twig_Cache_Null implements Twig_CacheInterface
|
||||
class NullCache implements CacheInterface
|
||||
{
|
||||
public function generateKey($name, $className)
|
||||
{
|
||||
@@ -37,4 +39,4 @@ class Twig_Cache_Null implements Twig_CacheInterface
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('Twig_Cache_Null', 'Twig\Cache\NullCache', false);
|
||||
class_alias('Twig\Cache\NullCache', 'Twig_Cache_Null');
|
Reference in New Issue
Block a user