8000 [Config] Do not use absolute path when computing the vendor freshness · symfony/symfony@6b30fc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b30fc0

Browse files
committed
[Config] Do not use absolute path when computing the vendor freshness
When one uses Docker with a different mounting point between CLI & FPM, the cache keeps regenerating because the ComposerResource class see a different path for each SAPI. For example `/home/app/app/vendor` vs `/var/www/app/vendor`. So if you hit FPM, then the CLI, then FPM, each time a new cache is generated. So the application is quite slow in dev env. And for people on MacOSX (with docker) is a big pain! And obvisouly, this never stabilizes ! This occurs a lot when you have a worker, that crash and reboot in the background, and you browse the web interface. Or when you have something that hit your API every X secondes, and you are working on a worker.
1 parent 04b9ce3 commit 6b30fc0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/Config/Resource/ComposerResource.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ private static function refresh()
7171
{
7272
self::$runtimeVendors = [];
7373

74+
$i = 0;
7475
foreach (get_declared_classes() as $class) {
7576
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
7677
$r = new \ReflectionClass($class);
7778
$v = \dirname(\dirname($r->getFileName()));
7879
if (file_exists($v.'/composer/installed.json')) {
79-
self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
80+
self::$runtimeVendors["__vendor_$i"] = @filemtime($v.'/composer/installed.json');
81+
++$i;
8082
}
8183
}
8284
}

src/Symfony/Component/Config/Tests/Resource/ComposerResourceTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ public function testGetVendor()
2121
{
2222
$res = new ComposerResource();
2323

24-
$r = new \ReflectionClass(ClassLoader::class);
2524
$found = false;
2625

2726
foreach ($res->getVendors() as $vendor) {
28-
if ($vendor && 0 === strpos($r->getFileName(), $vendor)) {
27+
if ($vendor && 0 === strpos('__vendor_0', $vendor)) {
2928
$found = true;
3029
break;
3130
}

0 commit comments

Comments
 (0)
0