[Translation] fix memoryleak in PhpFileLoader
This commit is contained in:
parent
42712ee006
commit
5c9e3bac96
@ -18,11 +18,25 @@ namespace Symfony\Component\Translation\Loader;
|
|||||||
*/
|
*/
|
||||||
class PhpFileLoader extends FileLoader
|
class PhpFileLoader extends FileLoader
|
||||||
{
|
{
|
||||||
|
private static $cache = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function loadResource($resource)
|
protected function loadResource($resource)
|
||||||
{
|
{
|
||||||
|
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||||
|
self::$cache = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === self::$cache) {
|
||||||
return require $resource;
|
return require $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset(self::$cache[$resource])) {
|
||||||
|
return self::$cache[$resource];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$cache[$resource] = require $resource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user