Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PoolBuilder.php

function PoolBuilder::unlockPackage

Reverts the decision to use a locked package if a partial update with transitive dependencies found that this package actually needs to be updated

Parameters

RepositoryInterface[] $repositories:

1 call to PoolBuilder::unlockPackage()
PoolBuilder::loadPackage in vendor/composer/composer/src/Composer/DependencyResolver/PoolBuilder.php

File

vendor/composer/composer/src/Composer/DependencyResolver/PoolBuilder.php, line 662

Class

PoolBuilder
@author Nils Adermann <naderman@naderman.de>

Namespace

Composer\DependencyResolver

Code

private function unlockPackage(Request $request, array $repositories, string $name) : void {
    foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
        // if we unfixed a replaced package name, we also need to unfix the replacer itself
        // as long as it was not unfixed yet
        if ($packageOrReplacer->getName() !== $name && isset($this->skippedLoad[$packageOrReplacer->getName()])) {
            $replacerName = $packageOrReplacer->getName();
            if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $name) && !$this->isRootRequire($request, $replacerName)) {
                $this->unlockPackage($request, $repositories, $replacerName);
                if ($this->isRootRequire($request, $replacerName)) {
                    $this->markPackageNameForLoading($request, $replacerName, new MatchAllConstraint());
                }
                else {
                    foreach ($this->packages as $loadedPackage) {
                        $requires = $loadedPackage->getRequires();
                        if (isset($requires[$replacerName])) {
                            $this->markPackageNameForLoading($request, $replacerName, $requires[$replacerName]->getConstraint());
                        }
                    }
                }
            }
        }
    }
    if (isset($this->pathRepoUnlocked[$name])) {
        foreach ($this->packages as $index => $package) {
            if ($package->getName() === $name) {
                $this->removeLoadedPackage($request, $repositories, $package, $index);
            }
        }
    }
    unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name], $this->pathRepoUnlocked[$name]);
    // remove locked package by this name which was already initialized
    foreach ($request->getLockedPackages() as $lockedPackage) {
        if (!$lockedPackage instanceof AliasPackage && $lockedPackage->getName() === $name) {
            if (false !== ($index = array_search($lockedPackage, $this->packages, true))) {
                $request->unlockPackage($lockedPackage);
                $this->removeLoadedPackage($request, $repositories, $lockedPackage, $index);
                // make sure that any requirements for this package by other locked or fixed packages are now
                // also loaded, as they were previously ignored because the locked (now unlocked) package already
                // satisfied their requirements
                // and if this package is replacing another that is required by a locked or fixed package, ensure
                // that we load that replaced package in case an update to this package removes the replacement
                foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
                    if ($fixedOrLockedPackage === $lockedPackage) {
                        continue;
                    }
                    if (isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
                        $requires = $fixedOrLockedPackage->getRequires();
                        if (isset($requires[$lockedPackage->getName()])) {
                            $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]
                                ->getConstraint());
                        }
                        foreach ($lockedPackage->getReplaces() as $replace) {
                            if (isset($requires[$replace->getTarget()], $this->skippedLoad[$replace->getTarget()])) {
                                $this->unlockPackage($request, $repositories, $replace->getTarget());
                                // this package is in $requires so no need to call markPackageNameForLoadingIfRequired
                                $this->markPackageNameForLoading($request, $replace->getTarget(), $replace->getConstraint());
                            }
                        }
                    }
                }
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal