|
@@ -358,9 +358,12 @@ class Installer
|
|
|
$repositories = null;
|
|
|
|
|
|
// initialize locker to create aliased packages
|
|
|
- $installFromLock = false;
|
|
|
- if (!$this->update && $this->locker->isLocked()) {
|
|
|
- $installFromLock = true;
|
|
|
+ $installFromLock = !$this->update && $this->locker->isLocked();
|
|
|
+
|
|
|
+ // initialize locked repo if we are installing from lock or in a partial update
|
|
|
+ // and a lock file is present as we need to force install non-whitelisted lock file
|
|
|
+ // packages in that case
|
|
|
+ if ($installFromLock || (!empty($this->updateWhitelist) && $this->locker->isLocked())) {
|
|
|
try {
|
|
|
$lockedRepository = $this->locker->getLockedRepository($withDevReqs);
|
|
|
} catch (\RuntimeException $e) {
|
|
@@ -384,18 +387,20 @@ class Installer
|
|
|
|
|
|
// creating repository pool
|
|
|
$policy = $this->createPolicy();
|
|
|
- $pool = $this->createPool($withDevReqs, $lockedRepository);
|
|
|
+ $pool = $this->createPool($withDevReqs, $installFromLock ? $lockedRepository : null);
|
|
|
$pool->addRepository($installedRepo, $aliases);
|
|
|
- if ($installFromLock) {
|
|
|
- $pool->addRepository($lockedRepository, $aliases);
|
|
|
- }
|
|
|
-
|
|
|
if (!$installFromLock) {
|
|
|
$repositories = $this->repositoryManager->getRepositories();
|
|
|
foreach ($repositories as $repository) {
|
|
|
$pool->addRepository($repository, $aliases);
|
|
|
}
|
|
|
}
|
|
|
+ // Add the locked repository after the others in case we are doing a
|
|
|
+ // partial update so missing packages can be found there still.
|
|
|
+ // For installs from lock it's the only one added so it is first
|
|
|
+ if ($lockedRepository) {
|
|
|
+ $pool->addRepository($lockedRepository, $aliases);
|
|
|
+ }
|
|
|
|
|
|
// creating requirements request
|
|
|
$request = $this->createRequest($pool, $this->package, $platformRepo);
|
|
@@ -432,16 +437,7 @@ class Installer
|
|
|
// if the updateWhitelist is enabled, packages not in it are also fixed
|
|
|
// to the version specified in the lock, or their currently installed version
|
|
|
if ($this->updateWhitelist) {
|
|
|
- if ($this->locker->isLocked()) {
|
|
|
- try {
|
|
|
- $currentPackages = $this->locker->getLockedRepository($withDevReqs)->getPackages();
|
|
|
- } catch (\RuntimeException $e) {
|
|
|
- // fetch only non-dev packages from lock if doing a dev update fails due to a previously incomplete lock file
|
|
|
- $currentPackages = $this->locker->getLockedRepository()->getPackages();
|
|
|
- }
|
|
|
- } else {
|
|
|
- $currentPackages = $installedRepo->getPackages();
|
|
|
- }
|
|
|
+ $currentPackages = $this->getCurrentPackages($withDevReqs, $installedRepo);
|
|
|
|
|
|
// collect packages to fixate from root requirements as well as installed packages
|
|
|
$candidates = array();
|
|
@@ -500,7 +496,7 @@ class Installer
|
|
|
}
|
|
|
|
|
|
// force dev packages to have the latest links if we update or install from a (potentially new) lock
|
|
|
- $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-links');
|
|
|
+ $this->processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, $installFromLock, $withDevReqs, 'force-links');
|
|
|
|
|
|
// solve dependencies
|
|
|
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
|
|
@@ -516,7 +512,7 @@ class Installer
|
|
|
}
|
|
|
|
|
|
// force dev packages to be updated if we update or install from a (potentially new) lock
|
|
|
- $operations = $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-updates', $operations);
|
|
|
+ $operations = $this->processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, $installFromLock, $withDevReqs, 'force-updates', $operations);
|
|
|
|
|
|
// execute operations
|
|
|
if (!$operations) {
|
|
@@ -768,7 +764,7 @@ class Installer
|
|
|
return $request;
|
|
|
}
|
|
|
|
|
|
- private function processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, $task, array $operations = null)
|
|
|
+ private function processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, $installFromLock, $withDevReqs, $task, array $operations = null)
|
|
|
{
|
|
|
if ($task === 'force-updates' && null === $operations) {
|
|
|
throw new \InvalidArgumentException('Missing operations argument');
|
|
@@ -777,6 +773,10 @@ class Installer
|
|
|
$operations = array();
|
|
|
}
|
|
|
|
|
|
+ if (!$installFromLock && $this->updateWhitelist) {
|
|
|
+ $currentPackages = $this->getCurrentPackages($withDevReqs, $installedRepo);
|
|
|
+ }
|
|
|
+
|
|
|
foreach ($localRepo->getCanonicalPackages() as $package) {
|
|
|
// skip non-dev packages
|
|
|
if (!$package->isDev()) {
|
|
@@ -817,6 +817,26 @@ class Installer
|
|
|
if ($this->update) {
|
|
|
// skip package if the whitelist is enabled and it is not in it
|
|
|
if ($this->updateWhitelist && !$this->isUpdateable($package)) {
|
|
|
+ // check if non-updateable packages are out of date compared to the lock file to ensure we don't corrupt it
|
|
|
+ foreach ($currentPackages as $curPackage) {
|
|
|
+ if ($curPackage->isDev() && $curPackage->getName() === $package->getName() && $curPackage->getVersion() === $package->getVersion()) {
|
|
|
+ if ($task === 'force-links') {
|
|
|
+ $package->setRequires($curPackage->getRequires());
|
|
|
+ $package->setConflicts($curPackage->getConflicts());
|
|
|
+ $package->setProvides($curPackage->getProvides());
|
|
|
+ $package->setReplaces($curPackage->getReplaces());
|
|
|
+ } elseif ($task === 'force-updates') {
|
|
|
+ if (($curPackage->getSourceReference() && $curPackage->getSourceReference() !== $package->getSourceReference())
|
|
|
+ || ($curPackage->getDistReference() && $curPackage->getDistReference() !== $package->getDistReference())
|
|
|
+ ) {
|
|
|
+ $operations[] = new UpdateOperation($package, $curPackage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -874,6 +894,23 @@ class Installer
|
|
|
return $operations;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Loads the most "current" list of packages that are installed meaning from lock ideally or from installed repo as fallback
|
|
|
+ */
|
|
|
+ private function getCurrentPackages($withDevReqs, $installedRepo)
|
|
|
+ {
|
|
|
+ if ($this->locker->isLocked()) {
|
|
|
+ try {
|
|
|
+ return $this->locker->getLockedRepository($withDevReqs)->getPackages();
|
|
|
+ } catch (\RuntimeException $e) {
|
|
|
+ // fetch only non-dev packages from lock if doing a dev update fails due to a previously incomplete lock file
|
|
|
+ return $this->locker->getLockedRepository()->getPackages();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $installedRepo->getPackages();
|
|
|
+ }
|
|
|
+
|
|
|
private function getRootAliases()
|
|
|
{
|
|
|
if (!$this->update && $this->locker->isLocked()) {
|