From b5aad9ec0d8881be1314ea356dbc05ae4492ec87 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 24 Feb 2023 17:41:59 +0100 Subject: [PATCH] Fix type error when upgrading composer --- src/Composer/Repository/FilesystemRepository.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index 901a5ef16..abe76950d 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -163,9 +163,13 @@ class FilesystemRepository extends WritableArrayRepository $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', 'dumpToPhpCode($versions) . ';'."\n"); $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php'); - $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass); - \Composer\InstalledVersions::reload($versions); + // this normally should not happen but during upgrades of Composer when it is installed in the project it is a possibility + if ($installedVersionsClass !== false) { + $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass); + + \Composer\InstalledVersions::reload($versions); + } } }