Fix memory usage of the update command
parent
e1bd2fd6df
commit
c14bc368b0
|
@ -391,7 +391,14 @@ class Installer
|
|||
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()) {
|
||||
$operations[] = new UpdateOperation($package, $newPackage);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|||
protected $io;
|
||||
protected $cache;
|
||||
protected $notifyUrl;
|
||||
protected $minimalPackages;
|
||||
protected $loader;
|
||||
private $rawData;
|
||||
private $minimalPackages;
|
||||
|
||||
public function __construct(array $repoConfig, IOInterface $io, Config $config)
|
||||
{
|
||||
|
@ -90,12 +91,14 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|||
return $this->minimalPackages;
|
||||
}
|
||||
|
||||
$repoData = $this->loadDataFromServer();
|
||||
if (null === $this->rawData) {
|
||||
$this->rawData = $this->loadDataFromServer();
|
||||
}
|
||||
|
||||
$this->minimalPackages = array();
|
||||
$versionParser = new VersionParser;
|
||||
|
||||
foreach ($repoData as $package) {
|
||||
foreach ($this->rawData as $package) {
|
||||
$version = !empty($package['version_normalized']) ? $package['version_normalized'] : $versionParser->normalize($package['version']);
|
||||
$data = array(
|
||||
'name' => strtolower($package['name']),
|
||||
|
@ -127,9 +130,11 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|||
*/
|
||||
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))) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue