Browse Source

Minor fixes

Jordi Boggiano 11 years ago
parent
commit
b39df32d4b
2 changed files with 21 additions and 19 deletions
  1. 7 5
      src/Composer/Package/Package.php
  2. 14 14
      src/Composer/Util/ComposerMirror.php

+ 7 - 5
src/Composer/Package/Package.php

@@ -582,15 +582,17 @@ class Package extends BasePackage
 
     protected function getUrls($url, $mirrors, $ref, $type)
     {
-        $urls = array();
-        if ($url) {
-            $urls[] = $url;
+        if (!$url) {
+            return array();
         }
+        $urls = array($url);
         if ($mirrors) {
             foreach ($mirrors as $mirror) {
                 $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
-                $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
-                $func($urls, $mirrorUrl);
+                if (!in_array($urls, $mirrorUrl)) {
+                    $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
+                    $func($urls, $mirrorUrl);
+                }
             }
         }
 

+ 14 - 14
src/Composer/Util/ComposerMirror.php

@@ -1,22 +1,22 @@
 <?php
 
-
-
-
-
-
-
-
-
-
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ *     Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
 namespace Composer\Util;
 
-
-
-
-
-
+/**
+ * Composer mirror utilities
+ *
+ * @author Jordi Boggiano <j.boggiano@seld.be>
+ */
 class ComposerMirror
 {
     public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)