bug #18312 [ClassLoader] Fix storing not-found classes in APC cache (nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[ClassLoader] Fix storing not-found classes in APC cache

| Q             | A
| ------------- | ---
| Branch?       | 2.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

106ed06 [ClassLoader] Fix storing not-found classes in APC cache
This commit is contained in:
Tobias Schultze 2016-03-28 21:27:59 +02:00
commit 666dc41d0e
5 changed files with 14 additions and 8 deletions

View File

@ -122,8 +122,10 @@ class ApcClassLoader
*/
public function findFile($class)
{
if (false === $file = apcu_fetch($this->prefix.$class)) {
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class));
$file = apcu_fetch($this->prefix.$class, $success);
if (!$success) {
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
}
return $file;

View File

@ -87,8 +87,10 @@ class ApcUniversalClassLoader extends UniversalClassLoader
*/
public function findFile($class)
{
if (false === $file = apcu_fetch($this->prefix.$class)) {
apcu_store($this->prefix.$class, $file = parent::findFile($class));
$file = apcu_fetch($this->prefix.$class, $success);
if (!$success) {
apcu_store($this->prefix.$class, $file = parent::findFile($class) ?: null);
}
return $file;

View File

@ -74,7 +74,7 @@ class DebugClassLoader
*/
public function findFile($class)
{
return $this->classFinder->findFile($class);
return $this->classFinder->findFile($class) ?: null;
}
/**

View File

@ -123,8 +123,10 @@ class WinCacheClassLoader
*/
public function findFile($class)
{
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
$file = wincache_ucache_get($this->prefix.$class, $success);
if (!$success) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0);
}
return $file;

View File

@ -126,7 +126,7 @@ class XcacheClassLoader
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
$file = $this->decorated->findFile($class);
$file = $this->decorated->findFile($class) ?: null;
xcache_set($this->prefix.$class, $file);
}