Always load the current InstalledVersions when writing to disk, fixes #9457
parent
14d20776a2
commit
fec44f883c
|
@ -335,6 +335,11 @@ class Factory
|
||||||
if ($fullLoad) {
|
if ($fullLoad) {
|
||||||
// load auth configs into the IO instance
|
// load auth configs into the IO instance
|
||||||
$io->loadConfiguration($config);
|
$io->loadConfiguration($config);
|
||||||
|
|
||||||
|
// load existing Composer\InstalledVersions instance if available
|
||||||
|
if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
|
||||||
|
include $installedVersionsPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$httpDownloader = self::createHttpDownloader($io, $config);
|
$httpDownloader = self::createHttpDownloader($io, $config);
|
||||||
|
|
|
@ -206,6 +206,14 @@ class FilesystemRepository extends WritableArrayRepository
|
||||||
$installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
|
$installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
|
||||||
$installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
|
$installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
|
||||||
$fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
|
$fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
|
||||||
|
|
||||||
|
// make sure the InstalledVersions class is loaded and has the latest state
|
||||||
|
// not using the autoloader here to avoid loading the one from Composer's vendor dir
|
||||||
|
if (!class_exists('Composer\InstalledVersions', false)) {
|
||||||
|
include $repoDir.'/InstalledVersions.php';
|
||||||
|
} else {
|
||||||
|
\Composer\InstalledVersions::reload($versions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue