Skip to content

Instantly share code, notes, and snippets.

@Nicofuma
Created September 5, 2016 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nicofuma/55fa830df388fce56058850f9341ee41 to your computer and use it in GitHub Desktop.
Save Nicofuma/55fa830df388fce56058850f9341ee41 to your computer and use it in GitHub Desktop.
Patch to skip invalid packages in cmposer repositories
diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php
index 78ef743..d91d471 100644
--- a/src/Composer/Repository/ComposerRepository.php
+++ b/src/Composer/Repository/ComposerRepository.php
@@ -343,6 +343,7 @@ public function whatProvides(Pool $pool, $name, $bypassFilters = false)
$this->providers[$name] = array();
foreach ($packages['packages'] as $versions) {
foreach ($versions as $version) {
+ try {
// avoid loading the same objects twice
if (isset($this->providersByUid[$version['uid']])) {
// skip if already assigned
@@ -399,6 +400,9 @@ public function whatProvides(Pool $pool, $name, $bypassFilters = false)
$this->providersByUid[$version['uid'] . '-root'] = $alias;
}
}
+ } catch (\RuntimeException $e) {
+ $this->io->writeError('Could not load a package: '. $e->getMessage());
+ }
}
}
@@ -426,7 +430,11 @@ protected function initialize()
$repoData = $this->loadDataFromServer();
foreach ($repoData as $package) {
+ try {
$this->addPackage($this->createPackage($package, 'Composer\Package\CompletePackage'));
+ } catch (\RuntimeException $e) {
+ $this->io->writeError('Could not load a package: '. $e->getMessage());
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment