Skip to content

Commit c99c74b

Browse files
committed
bug #57645 [Routing] Discard in-memory cache of routes when writing the file-based cache (mpdude)
This PR was merged into the 5.4 branch. Discussion ---------- [Routing] Discard in-memory cache of routes when writing the file-based cache | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57640 | License | MIT The `Router` has a `private static ?array $cache` field that it uses to cache compiled route collections in the case that OpCache is not available to cache the file-based cache already. This is somewhat [a poor man's Opcache replacement](symfony/symfony#57640 (comment)), useful e. g. for speedups during (functional) tests. `\Symfony\Component\Config\ResourceCheckerConfigCache::write` contains special code to make sure the OpCache will reload files after they have been written, but the `static` property kind of "hides" this feature. With this PR, the `static` cache entry is cleared as well. Commits ------- de7d8849eb [Router] Discard in-memory cache of routes when writing the file-based cache
2 parents 6df1dd8 + 7bec6df commit c99c74b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Router.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ function (ConfigCacheInterface $cache) {
294294
}
295295

296296
$cache->write($dumper->dump(), $this->getRouteCollection()->getResources());
297+
unset(self::$cache[$cache->getPath()]);
297298
}
298299
);
299300

@@ -325,6 +326,7 @@ function (ConfigCacheInterface $cache) {
325326
$dumper = $this->getGeneratorDumperInstance();
326327

327328
$cache->write($dumper->dump(), $this->getRouteCollection()->getResources());
329+
unset(self::$cache[$cache->getPath()]);
328330
}
329331
);
330332

0 commit comments

Comments
 (0)