1
0
Fork 0

Fix memory usage of the update command

pull/1015/head
Jordi Boggiano 2012-08-24 02:29:03 +02:00
parent e1bd2fd6df
commit c14bc368b0
2 changed files with 18 additions and 6 deletions

View File

@ -391,7 +391,14 @@ class Installer
continue; continue;
} }
$newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion()); $newPackage = null;
$matches = $pool->whatProvides($package->getName(), new VersionConstraint('=', $package->getVersion()));
foreach ($matches as $match) {
if (null === $newPackage || $newPackage->getReleaseDate() < $match->getReleaseDate()) {
$newPackage = $match;
}
}
if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) { if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
$operations[] = new UpdateOperation($package, $newPackage); $operations[] = new UpdateOperation($package, $newPackage);
} }

View File

@ -31,8 +31,9 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
protected $io; protected $io;
protected $cache; protected $cache;
protected $notifyUrl; protected $notifyUrl;
protected $minimalPackages;
protected $loader; protected $loader;
private $rawData;
private $minimalPackages;
public function __construct(array $repoConfig, IOInterface $io, Config $config) public function __construct(array $repoConfig, IOInterface $io, Config $config)
{ {
@ -90,12 +91,14 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
return $this->minimalPackages; return $this->minimalPackages;
} }
$repoData = $this->loadDataFromServer(); if (null === $this->rawData) {
$this->rawData = $this->loadDataFromServer();
}
$this->minimalPackages = array(); $this->minimalPackages = array();
$versionParser = new VersionParser; $versionParser = new VersionParser;
foreach ($repoData as $package) { foreach ($this->rawData as $package) {
$version = !empty($package['version_normalized']) ? $package['version_normalized'] : $versionParser->normalize($package['version']); $version = !empty($package['version_normalized']) ? $package['version_normalized'] : $versionParser->normalize($package['version']);
$data = array( $data = array(
'name' => strtolower($package['name']), 'name' => strtolower($package['name']),
@ -127,9 +130,11 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
*/ */
public function filterPackages($callback, $class = 'Composer\Package\Package') public function filterPackages($callback, $class = 'Composer\Package\Package')
{ {
$repoData = $this->loadDataFromServer(); if (null === $this->rawData) {
$this->rawData = $this->loadDataFromServer();
}
foreach ($repoData as $package) { foreach ($this->rawData as $package) {
if (false === $callback($package = $this->loader->load($package, $class))) { if (false === $callback($package = $this->loader->load($package, $class))) {
return false; return false;
} }