From b8b2d1672dc3d43f8af2b73cff0cf836db773063 Mon Sep 17 00:00:00 2001 From: Austin McKinley Date: Tue, 5 Jun 2018 15:57:30 -0700 Subject: [PATCH] Prevent creation of empty repository identities Summary: Fixes issue reported in https://secure.phabricator.com/rPf191a66490b194785fae28c062b71be99bb14584#43240 Test Plan: Imported an SVN repo, observed clean import instead of daemon exception. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D19466 --- ...torRepositoryCommitMessageParserWorker.php | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index 7f3bfa2ad9..8a1b5e5dd1 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -80,18 +80,22 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker ->save(); } - $committer_identity = id(new PhabricatorRepositoryIdentityQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withIdentityNames(array($committer)) - ->executeOne(); + $committer_identity = null; - if (!$committer_identity) { - $committer_identity = id(new PhabricatorRepositoryIdentity()) - ->setAuthorPHID($commit->getPHID()) - ->setIdentityName($committer) - ->setAutomaticGuessedUserPHID( - $this->resolveUserPHID($commit, $committer)) - ->save(); + if ($committer) { + $committer_identity = id(new PhabricatorRepositoryIdentityQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withIdentityNames(array($committer)) + ->executeOne(); + + if (!$committer_identity) { + $committer_identity = id(new PhabricatorRepositoryIdentity()) + ->setAuthorPHID($commit->getPHID()) + ->setIdentityName($committer) + ->setAutomaticGuessedUserPHID( + $this->resolveUserPHID($commit, $committer)) + ->save(); + } } $data = id(new PhabricatorRepositoryCommitData())->loadOneWhere( @@ -128,6 +132,8 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker $this->resolveUserPHID($commit, $committer)); $data->setCommitDetail( 'committerIdentityPHID', $committer_identity->getPHID()); + + $commit->setCommitterIdentityPHID($committer_identity->getPHID()); } $repository = $this->repository; @@ -166,7 +172,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker } $commit->setAuthorIdentityPHID($author_identity->getPHID()); - $commit->setCommitterIdentityPHID($committer_identity->getPHID()); $commit->setSummary($data->getSummary()); $commit->save();