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

Breadcrumb

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

function LockTransaction::updateMirrorAndUrls

Try to return the original package from presentMap with updated URLs/mirrors

If the type of source/dist changed, then we do not update those and keep them as they were

1 call to LockTransaction::updateMirrorAndUrls()
LockTransaction::getNewLockPackages in vendor/composer/composer/src/Composer/DependencyResolver/LockTransaction.php

File

vendor/composer/composer/src/Composer/DependencyResolver/LockTransaction.php, line 127

Class

LockTransaction
@author Nils Adermann <naderman@naderman.de> @internal

Namespace

Composer\DependencyResolver

Code

private function updateMirrorAndUrls(BasePackage $package) : BasePackage {
    foreach ($this->presentMap as $presentPackage) {
        if ($package->getName() !== $presentPackage->getName()) {
            continue;
        }
        if ($package->getVersion() !== $presentPackage->getVersion()) {
            continue;
        }
        if ($presentPackage->getSourceReference() === null) {
            continue;
        }
        if ($presentPackage->getSourceType() !== $package->getSourceType()) {
            continue;
        }
        if ($presentPackage instanceof Package) {
            $presentPackage->setSourceUrl($package->getSourceUrl());
            $presentPackage->setSourceMirrors($package->getSourceMirrors());
        }
        // if the dist type changed, we only update the source url/mirrors
        if ($presentPackage->getDistType() !== $package->getDistType()) {
            return $presentPackage;
        }
        // update dist url if it is in a known format
        if ($package->getDistUrl() !== null && $presentPackage->getDistReference() !== null && Preg::isMatch('{^https?://(?:(?:www\\.)?bitbucket\\.org|(api\\.)?github\\.com|(?:www\\.)?gitlab\\.com)/}i', $package->getDistUrl())) {
            $presentPackage->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $presentPackage->getDistReference(), $package->getDistUrl()));
        }
        $presentPackage->setDistMirrors($package->getDistMirrors());
        return $presentPackage;
    }
    return $package;
}

API Navigation

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