Changed some variable names, continue 2, locked install changed
Changed some some instances of the $package variable name to be able to be consistent in all branches of the "add to request" section of code. Updated an instance of "break" to "continue 2" as it was resulting in the same package getting both update() and install() called on request. Seems like this is probably not needed, should be just one or the other? (could be way wrong on this) Gave "locked" branch of the update/locked/install code some logic to handle internally installed packages.pull/229/head
parent
c1ba2be345
commit
57ffc9d59b
|
@ -122,21 +122,20 @@ EOT
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if (isset($internallyInstalledPackagesMap[$link->getTarget()])) {
|
if (isset($internallyInstalledPackagesMap[$link->getTarget()])) {
|
||||||
$package = $internallyInstalledPackagesMap[$link->getTarget()];
|
$internallyInstalledPackage = $internallyInstalledPackagesMap[$link->getTarget()];
|
||||||
if (!$link->getConstraint()->matches(new VersionConstraint('=', $package->getVersion()))) {
|
if (!$link->getConstraint()->matches(new VersionConstraint('=', $internallyInstalledPackage->getVersion()))) {
|
||||||
// Solver was not handling this well so we will
|
// Solver was not handling this well so we will
|
||||||
// handle it here where we can do something
|
// handle it here.
|
||||||
// nice in the way of output.
|
throw new \UnexpectedValueException('Package '.$internallyInstalledPackage->getName().' can not be updated because its version constraint ('.$link->getPrettyConstraint().') is not compatible with internally installed version ('.$internallyInstalledPackage->getPrettyVersion().')');
|
||||||
throw new \UnexpectedValueException('Package '.$package->getName().' can not be updated because its version constraint ('.$link->getPrettyConstraint().') is not compatible with previously installed version ('.$package->getPrettyVersion().')');
|
|
||||||
}
|
}
|
||||||
// This package is installed internally, no need to
|
// This package is installed internally and has already
|
||||||
// install it again.
|
// been added to the request.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ($installedPackages as $package) {
|
foreach ($installedPackages as $package) {
|
||||||
if ($package->getName() === $link->getTarget()) {
|
if ($package->getName() === $link->getTarget()) {
|
||||||
$request->update($package->getName(), new VersionConstraint('=', $package->getVersion()));
|
$request->update($package->getName(), new VersionConstraint('=', $package->getVersion()));
|
||||||
break;
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +150,17 @@ EOT
|
||||||
|
|
||||||
foreach ($composer->getLocker()->getLockedPackages() as $package) {
|
foreach ($composer->getLocker()->getLockedPackages() as $package) {
|
||||||
$constraint = new VersionConstraint('=', $package->getVersion());
|
$constraint = new VersionConstraint('=', $package->getVersion());
|
||||||
|
if (isset($internallyInstalledPackagesMap[$package->getName()])) {
|
||||||
|
$internallyInstalledPackage = $internallyInstalledPackagesMap[$package->getName()];
|
||||||
|
if (!$constraint->matches(new VersionConstraint('=', $internallyInstalledPackage->getVersion()))) {
|
||||||
|
// Solver was not handling this well so we will
|
||||||
|
// handle it here.
|
||||||
|
throw new \UnexpectedValueException('Package '.$package->getName().' can not be installed because its version constraint ('.$package->getPrettyVersion().') is not compatible with internally installed version ('.$internallyInstalledPackage->getPrettyVersion().')');
|
||||||
|
}
|
||||||
|
// This package is installed internally and has already
|
||||||
|
// been added to the request.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$request->install($package->getName(), $constraint);
|
$request->install($package->getName(), $constraint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,15 +170,14 @@ EOT
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if (isset($internallyInstalledPackagesMap[$link->getTarget()])) {
|
if (isset($internallyInstalledPackagesMap[$link->getTarget()])) {
|
||||||
$package = $internallyInstalledPackagesMap[$link->getTarget()];
|
$internallyInstalledPackage = $internallyInstalledPackagesMap[$link->getTarget()];
|
||||||
if (!$link->getConstraint()->matches(new VersionConstraint('=', $package->getVersion()))) {
|
if (!$link->getConstraint()->matches(new VersionConstraint('=', $internallyInstalledPackage->getVersion()))) {
|
||||||
// Solver was not handling this well so we will
|
// Solver was not handling this well so we will
|
||||||
// handle it here where we can do something
|
// handle it here.
|
||||||
// nice in the way of output.
|
throw new \UnexpectedValueException('Package '.$internallyInstalledPackage->getName().' can not be installed because its version constraint ('.$link->getPrettyConstraint().') is not compatible with internally installed version ('.$internallyInstalledPackage->getPrettyVersion().')');
|
||||||
throw new \UnexpectedValueException('Package '.$package->getName().' can not be installed because its version constraint ('.$link->getPrettyConstraint().') is not compatible with previously installed version ('.$package->getPrettyVersion().')');
|
|
||||||
}
|
}
|
||||||
// This package is installed internally, no need to
|
// This package is installed internally and has already
|
||||||
// install it again.
|
// been added to the request.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$request->install($link->getTarget(), $link->getConstraint());
|
$request->install($link->getTarget(), $link->getConstraint());
|
||||||
|
|
Loading…
Reference in New Issue