New finding by Static Code Analysis
parent
006c921abd
commit
cd39efc72c
|
@ -543,16 +543,17 @@ class Installer
|
|||
|
||||
foreach ($operations as $operation) {
|
||||
// collect suggestions
|
||||
if ('install' === $operation->getJobType()) {
|
||||
$jobType = $operation->getJobType();
|
||||
if ('install' === $jobType) {
|
||||
$this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
|
||||
}
|
||||
|
||||
// updating, force dev packages' references if they're in root package refs
|
||||
if ($this->update) {
|
||||
$package = null;
|
||||
if ('update' === $operation->getJobType()) {
|
||||
if ('update' === $jobType) {
|
||||
$package = $operation->getTargetPackage();
|
||||
} elseif ('install' === $operation->getJobType()) {
|
||||
} elseif ('install' === $jobType) {
|
||||
$package = $operation->getPackage();
|
||||
}
|
||||
if ($package && $package->isDev()) {
|
||||
|
@ -561,20 +562,24 @@ class Installer
|
|||
$this->updateInstallReferences($package, $references[$package->getName()]);
|
||||
}
|
||||
}
|
||||
if ('update' === $operation->getJobType()
|
||||
&& $operation->getTargetPackage()->isDev()
|
||||
&& $operation->getTargetPackage()->getVersion() === $operation->getInitialPackage()->getVersion()
|
||||
&& (!$operation->getTargetPackage()->getSourceReference() || $operation->getTargetPackage()->getSourceReference() === $operation->getInitialPackage()->getSourceReference())
|
||||
&& (!$operation->getTargetPackage()->getDistReference() || $operation->getTargetPackage()->getDistReference() === $operation->getInitialPackage()->getDistReference())
|
||||
if ('update' === $jobType) {
|
||||
$targetPackage = $operation->getTargetPackage();
|
||||
if ($targetPackage->isDev()) {
|
||||
$initialPackage = $operation->getInitialPackage();
|
||||
if ($targetPackage->getVersion() === $initialPackage->getVersion()
|
||||
&& (!$targetPackage->getSourceReference() || $targetPackage->getSourceReference() === $initialPackage->getSourceReference())
|
||||
&& (!$targetPackage->getDistReference() || $targetPackage->getDistReference() === $initialPackage->getDistReference())
|
||||
) {
|
||||
$this->io->writeError(' - Skipping update of '. $operation->getTargetPackage()->getPrettyName().' to the same reference-locked version', true, IOInterface::DEBUG);
|
||||
$this->io->writeError(' - Skipping update of ' . $targetPackage->getPrettyName() . ' to the same reference-locked version', true, IOInterface::DEBUG);
|
||||
$this->io->writeError('', true, IOInterface::DEBUG);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($operation->getJobType());
|
||||
$event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($jobType);
|
||||
if (defined($event) && $this->runScripts) {
|
||||
$this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
|
||||
}
|
||||
|
@ -589,7 +594,7 @@ class Installer
|
|||
$this->installationManager->execute($localRepo, $operation);
|
||||
|
||||
// output reasons why the operation was ran, only for install/update operations
|
||||
if ($this->verbose && $this->io->isVeryVerbose() && in_array($operation->getJobType(), array('install', 'update'))) {
|
||||
if ($this->verbose && $this->io->isVeryVerbose() && in_array($jobType, array('install', 'update'))) {
|
||||
$reason = $operation->getReason();
|
||||
if ($reason instanceof Rule) {
|
||||
switch ($reason->getReason()) {
|
||||
|
@ -605,7 +610,7 @@ class Installer
|
|||
}
|
||||
}
|
||||
|
||||
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($operation->getJobType());
|
||||
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($jobType);
|
||||
if (defined($event) && $this->runScripts) {
|
||||
$this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ class ArchiveManager
|
|||
$nameParts = array(preg_replace('#[^a-z0-9-_]#i', '-', $package->getName()));
|
||||
|
||||
if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
|
||||
$nameParts = array_merge($nameParts, array($package->getDistReference(), $package->getDistType()));
|
||||
array_push($nameParts, $package->getDistReference(), $package->getDistType());
|
||||
} else {
|
||||
$nameParts = array_merge($nameParts, array($package->getPrettyVersion(), $package->getDistReference()));
|
||||
array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
|
||||
}
|
||||
|
||||
if ($package->getSourceReference()) {
|
||||
|
@ -144,7 +144,7 @@ class ArchiveManager
|
|||
$sourcePath = realpath('.');
|
||||
} else {
|
||||
// Directory used to download the sources
|
||||
$sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
|
||||
$sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid('', true);
|
||||
$filesystem->ensureDirectoryExists($sourcePath);
|
||||
|
||||
// Download sources
|
||||
|
@ -161,7 +161,7 @@ class ArchiveManager
|
|||
}
|
||||
|
||||
// Create the archive
|
||||
$tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
|
||||
$tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid('', true).'.'.$format;
|
||||
$filesystem->ensureDirectoryExists(dirname($tempTarget));
|
||||
|
||||
$archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
|
||||
|
|
|
@ -245,7 +245,7 @@ class Git
|
|||
|
||||
private function isAuthenticationFailure($url, &$match)
|
||||
{
|
||||
if (!preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match)) {
|
||||
if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -257,8 +257,9 @@ class Git
|
|||
'fatal: could not read Username',
|
||||
);
|
||||
|
||||
$errorOutput = $this->process->getErrorOutput();
|
||||
foreach ($authFailures as $authFailure) {
|
||||
if (strpos($this->process->getErrorOutput(), $authFailure) !== false) {
|
||||
if (strpos($errorOutput, $authFailure) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue