bug #29644 [Cache] fix bad optim (nicolas-grekas)
This PR was merged into the 4.2 branch.
Discussion
----------
[Cache] fix bad optim
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29643
| License | MIT
| Doc PR | -
Commits
-------
b76d4ea95f
[Cache] fix bad optim
This commit is contained in:
commit
9337422aa4
@ -31,8 +31,8 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
|
||||
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
|
||||
parent::__construct('', $defaultLifetime);
|
||||
$this->init($namespace, $directory);
|
||||
|
||||
$e = new \Exception();
|
||||
$this->includeHandler = function () use ($e) { throw $e; };
|
||||
$this->includeHandler = static function ($type, $msg, $file, $line) {
|
||||
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class PhpFilesCache extends AbstractCache implements PruneableInterface
|
||||
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
|
||||
parent::__construct('', $defaultLifetime);
|
||||
$this->init($namespace, $directory);
|
||||
|
||||
$e = new \Exception();
|
||||
$this->includeHandler = function () use ($e) { throw $e; };
|
||||
$this->includeHandler = static function ($type, $msg, $file, $line) {
|
||||
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,11 @@ trait PhpFilesTrait
|
||||
set_error_handler($this->includeHandler);
|
||||
try {
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
list($expiresAt) = include $file;
|
||||
try {
|
||||
list($expiresAt) = include $file;
|
||||
} catch (\ErrorException $e) {
|
||||
$expiresAt = $time;
|
||||
}
|
||||
|
||||
if ($time >= $expiresAt) {
|
||||
$pruned = $this->doUnlink($file) && !file_exists($file) && $pruned;
|
||||
@ -111,7 +115,7 @@ trait PhpFilesTrait
|
||||
if ($now >= $expiresAt) {
|
||||
unset($this->values[$id], $missingIds[$k]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\ErrorException $e) {
|
||||
unset($missingIds[$k]);
|
||||
}
|
||||
}
|
||||
@ -137,6 +141,8 @@ trait PhpFilesTrait
|
||||
try {
|
||||
$file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id);
|
||||
list($expiresAt, $value) = include $file;
|
||||
} catch (\ErrorException $e) {
|
||||
return false;
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
Reference in New Issue
Block a user