From f1163bdbd4684953cc7f08fe7467ea2a35cb5950 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 14 Nov 2024 11:05:32 +0100 Subject: [PATCH] Avoid updating the lock hash if there is no lock --- src/Composer/Command/BumpCommand.php | 2 +- src/Composer/Command/RequireCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/BumpCommand.php b/src/Composer/Command/BumpCommand.php index dc3df1e12..a87a65e1c 100644 --- a/src/Composer/Command/BumpCommand.php +++ b/src/Composer/Command/BumpCommand.php @@ -216,7 +216,7 @@ EOT $io->write('No requirements to update in '.$composerJsonPath.'.'); } - if (!$dryRun && $composer->getLocker()->isLocked() && $changeCount > 0) { + if (!$dryRun && $composer->getLocker()->isLocked() && $composer->getConfig()->get('lock') && $changeCount > 0) { $composer->getLocker()->updateHash($composerJson); } diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 92d0a77b5..59d1e0585 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -554,7 +554,7 @@ EOT if (!$dryRun) { $this->updateFile($this->json, $requirements, $requireKey, $removeKey, $sortPackages); - if ($locker->isLocked()) { + if ($locker->isLocked() && $composer->getConfig()->get('lock')) { $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $composer->getPackage()->getMinimumStability(), []); $locker->updateHash($this->json, function (array $lockData) use ($stabilityFlags) { foreach ($stabilityFlags as $packageName => $flag) {