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