Skip to content

Commit

Permalink
Merge branch '3.4' into 4.3
Browse files Browse the repository at this point in the history
* 3.4:
  [DoctrineBridge] try to fix deprecations from doctrine/persistence
  [Translation] fix memoryleak in PhpFileLoader
  • Loading branch information
nicolas-grekas committed Dec 12, 2019
2 parents 73f86a4 + 539bd22 commit 1a2b79e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Loader/PhpFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@
*/
class PhpFileLoader extends FileLoader
{
private static $cache = [];

/**
* {@inheritdoc}
*/
protected function loadResource($resource)
{
return require $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;
}

if (isset(self::$cache[$resource])) {
return self::$cache[$resource];
}

return self::$cache[$resource] = require $resource;
}
}

0 comments on commit 1a2b79e

Please sign in to comment.