8000 [ClassLoader] Fix storing not-found classes in APC cache · symfony/symfony@106ed06 · GitHub
[go: up one dir, main page]

Skip to content

Commit 106ed06

Browse files
[ClassLoader] Fix storing not-found classes in APC cache
1 parent 37dd041 commit 106ed06

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/Symfony/Component/ClassLoader/ApcClassLoader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ public function loadClass($class)
122122
*/
123123
public function findFile($class)
124124
{
125-
if (false === $file = apcu_fetch($this->prefix.$class)) {
126-
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class));
125+
$file = apcu_fetch($this->prefix.$class, $success);
126+
127+
if (!$success) {
128+
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
127129
}
128130

129131
return $file;

src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ public function __construct($prefix)
8787
*/
8888
public function findFile($class)
8989
{
90-
if (false === $file = apcu_fetch($this->prefix.$class)) {
91-
apcu_store($this->prefix.$class, $file = parent::findFile($class));
90+
$file = apcu_fetch($this->prefix.$class, $success);
91+
92+
if (!$success) {
93+
apcu_store($this->prefix.$class, $file = parent::findFile($class) ?: null);
9294
}
9395

9496
return $file;

src/Symfony/Component/ClassLoader/DebugClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function unregister()
7474
*/
7575
public function findFile($class)
7676
{
77-
return $this->classFinder->findFile($class);
77+
return $this->classFinder->findFile($class) ?: null;
7878
}
7979

8080
/**

src/Symfony/Component/ClassLoader/WinCacheClassLoader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ public function loadClass($class)
123123
*/
124124
public function findFile($class)
125125
{
126-
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
127-
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
126+
$file = wincache_ucache_get($this->prefix.$class, $success);
127+
128+
if (!$success) {
129+
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0);
128130
}
129131

130132
return $file;

src/Symfony/Component/ClassLoader/XcacheClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function findFile($class)
126126
if (xcache_isset($this->prefix.$class)) {
127127
$file = xcache_get($this->prefix.$class);
128128
} else {
129-
$file = $this->decorated->findFile($class);
129+
$file = $this->decorated->findFile($class) ?: null;
130130
xcache_set($this->prefix.$class, $file);
131131
}
132132

0 commit comments

Comments
 (0)
0