Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d2cbad

Browse files
committed
bug #50656 Only update autoload_runtime.php when it changed (Seldaek)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- Only update autoload_runtime.php when it changed | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> The vendor dir should not be changed if not necessary as this typically gets executed during deployment processes where permissions may not be sufficient, and it can mess up docker caching layers if filemtime changes unnecessarily. Commits ------- ca53525 Only update autoload_runtime.php when it changed
2 parents d979cfe + ca53525 commit 2d2cbad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Component/Runtime/Internal/ComposerPlugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ public function updateAutoloadFile(): void
105105
'%runtime_options%' => '['.substr(var_export($extra, true), 7, -1)." 'project_dir' => {$projectDir},\n]",
106106
]);
107107

108-
file_put_contents(substr_replace($autoloadFile, '_runtime', -4, 0), $code);
108+
// could use Composer\Util\Filesystem::filePutContentsIfModified once Composer 1.x support is dropped for this plugin
109+
$path = substr_replace($autoloadFile, '_runtime', -4, 0);
110+
$currentContent = @file_exists($path) ? @file_get_contents($path) : false;
111+
if (false === $currentContent || $currentContent !== $code) {
112+
file_put_contents($path, $code);
113+
}
109114
}
110115

111116
public static function getSubscribedEvents(): array

0 commit comments

Comments
 (0)