瀏覽代碼

Remove author auto-merging, fixes #278, fixes #383

Jordi Boggiano 11 年之前
父節點
當前提交
b1fdc21a50
共有 1 個文件被更改,包括 18 次插入14 次删除
  1. 18 14
      src/Packagist/WebBundle/Package/Updater.php

+ 18 - 14
src/Packagist/WebBundle/Package/Updater.php

@@ -261,25 +261,29 @@ class Updater
         if ($data->getAuthors()) {
             foreach ($data->getAuthors() as $authorData) {
                 $author = null;
-                // skip authors with no information
-                if (empty($authorData['email']) && empty($authorData['name'])) {
-                    continue;
-                }
 
-                if (!empty($authorData['email'])) {
-                    $author = $authorRepository->findOneByEmail($authorData['email']);
+                foreach (array('email', 'name', 'homepage', 'role') as $field) {
+                    if (isset($authorData[$field])) {
+                        $authorData[$field] = trim($authorData[$field]);
+                        if ('' === $authorData[$field]) {
+                            $authorData[$field] = null;
+                        }
+                    } else {
+                        $authorData[$field] = null;
+                    }
                 }
 
-                if (!$author && !empty($authorData['homepage'])) {
-                    $author = $authorRepository->findOneBy(array(
-                        'name' => $authorData['name'],
-                        'homepage' => $authorData['homepage']
-                    ));
+                // skip authors with no information
+                if (!isset($authorData['email']) && !isset($authorData['name'])) {
+                    continue;
                 }
 
-                if (!$author && !empty($authorData['name'])) {
-                    $author = $authorRepository->findOneByNameAndPackage($authorData['name'], $package);
-                }
+                $author = $authorRepository->findOneBy(array(
+                    'email' => $authorData['email'],
+                    'name' => $authorData['name'],
+                    'homepage' => $authorData['homepage'],
+                    'role' => $authorData['role'],
+                ));
 
                 if (!$author) {
                     $author = new Author();