diff --git a/bin/composer b/bin/composer
index 823f87a4b..88566e170 100755
--- a/bin/composer
+++ b/bin/composer
@@ -48,6 +48,8 @@ if (function_exists('ini_set')) {
unset($memoryInBytes, $memoryLimit);
}
+putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
+
// run the command application
$application = new Application();
$application->run(null, $output);
diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php
index 796dbdeb9..4e443d337 100644
--- a/src/Composer/Command/CreateProjectCommand.php
+++ b/src/Composer/Command/CreateProjectCommand.php
@@ -23,6 +23,7 @@ use Composer\Package\BasePackage;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\Package\Version\VersionSelector;
+use Composer\Package\AliasPackage;
use Composer\Repository\RepositoryFactory;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
@@ -330,6 +331,10 @@ EOT
$io->writeError('Plugins have been disabled.');
}
+ if ($package instanceof AliasPackage) {
+ $package = $package->getAliasOf();
+ }
+
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
$package->setSourceReference(substr($package->getPrettyVersion(), 4));
}
diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php
index ffc2af132..b90ba2edc 100644
--- a/src/Composer/Command/ShowCommand.php
+++ b/src/Composer/Command/ShowCommand.php
@@ -173,7 +173,7 @@ EOT
}
$io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
- return;
+ return 1;
}
} else {
$versions = array($package->getPrettyVersion() => $package->getVersion());
diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php
index 892c0af9d..a2165ea76 100644
--- a/src/Composer/Console/Application.php
+++ b/src/Composer/Console/Application.php
@@ -166,7 +166,7 @@ class Application extends BaseApplication
$io->writeError('Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.');
}
- if (extension_loaded('xdebug') && (!getenv('COMPOSER_DISABLE_XDEBUG_WARN') || getenv('COMPOSER_ALLOW_XDEBUG'))) {
+ if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
$io->writeError('You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug');
}
diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php
index e6cc378a0..b74d34858 100644
--- a/src/Composer/EventDispatcher/EventDispatcher.php
+++ b/src/Composer/EventDispatcher/EventDispatcher.php
@@ -175,12 +175,7 @@ class EventDispatcher
$args = $event->getArguments();
$flags = $event->getFlags();
if (substr($callable, 0, 10) === '@composer ') {
- $finder = new PhpExecutableFinder();
- $phpPath = $finder->find();
- if (!$phpPath) {
- throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName);
- }
- $exec = $phpPath . ' ' . realpath($_SERVER['argv'][0]) . substr($callable, 9);
+ $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
if (0 !== ($exitCode = $this->process->execute($exec))) {
$this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()));
@@ -234,12 +229,7 @@ class EventDispatcher
}
if (substr($exec, 0, 5) === '@php ') {
- $finder = new PhpExecutableFinder();
- $phpPath = $finder->find();
- if (!$phpPath) {
- throw new \RuntimeException('Failed to locate PHP binary to execute "'.$exec.'"');
- }
- $exec = $phpPath . ' ' . substr($exec, 5);
+ $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
}
if (0 !== ($exitCode = $this->process->execute($exec))) {
@@ -259,6 +249,19 @@ class EventDispatcher
return $return;
}
+ protected function getPhpExecCommand()
+ {
+ $finder = new PhpExecutableFinder();
+ $phpPath = $finder->find();
+ if (!$phpPath) {
+ throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName);
+ }
+
+ $memoryFlag = ' -d memory_limit='.ini_get('memory_limit');
+
+ return ProcessExecutor::escape($phpPath) . $memoryFlag;
+ }
+
/**
* @param string $className
* @param string $methodName
diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php
index ec8157456..9f6fa5d04 100644
--- a/src/Composer/Installer.php
+++ b/src/Composer/Installer.php
@@ -605,7 +605,7 @@ class Installer
$this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
}
- if ($this->executeOperations) {
+ if ($this->executeOperations || $this->writeLock) {
$localRepo->write();
}
}