Browse Source

Change the content hash to be only based on values that affect dependency resolution

Zsolt Szeberenyi 10 years ago
parent
commit
3e0219c438
1 changed files with 21 additions and 2 deletions
  1. 21 2
      src/Composer/Factory.php

+ 21 - 2
src/Composer/Factory.php

@@ -496,7 +496,26 @@ class Factory
     private function getContentHash($composerFilePath)
     private function getContentHash($composerFilePath)
     {
     {
         $content = json_decode(file_get_contents($composerFilePath), true);
         $content = json_decode(file_get_contents($composerFilePath), true);
-        ksort($content);
-        return md5(json_encode($content));
+
+        $relevantKeys = array(
+            'require',
+            'require-dev',
+            'conflict',
+            'replace',
+            'provide',
+            'suggest',
+            'minimum-stability',
+            'prefer-stable',
+            'repositories',
+        );
+
+        $relevantContent = array();
+
+        foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
+            $relevantContent[$key] = $content[$key];
+        }
+
+        ksort($relevantContent);
+        return md5(json_encode($relevantContent));
     }
     }
 }
 }