Page MenuHomePhabricator
Paste P2031

sell_private_user_data_to_the_highest_bidder.diff
ActivePublic

Authored by epriestley on Feb 13 2017, 4:24 PM.
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
index 415c46bb27..1814355cfd 100644
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -313,6 +313,38 @@ final class DifferentialDiff
}
}
+ // If we were unable to pull authorship data from commit metadata and
+ // this diff is associated with a revision, use the revision author's
+ // account details instead.
+ if (!strlen(idx($dict, 'authorEmail'))) {
+ if ($this->hasRevision()) {
+ $viewer = PhabricatorUser::getOmnipotentUser();
+
+ $revision = $this->getRevision();
+ $author_phid = $revision->getAuthorPHID();
+
+ $author = id(new PhabricatorUserQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($author_phid))
+ ->executeOne();
+ if ($author) {
+ $email = id(new PhabricatorUserEmail())->loadOneWhere(
+ 'userPHID = %s AND isPrimary = 1',
+ $author->getPHID());
+ if ($email) {
+ $author_name = $author->getRealName();
+ if (!strlen($author_name)) {
+ $author_name = $author->getUsername();
+ }
+ $author_email = $email->getAddress();
+
+ $dict['authorName'] = $author_name;
+ $dict['authorEmail'] = $author_email;
+ }
+ }
+ }
+ }
+
return $dict;
}

Event Timeline

epriestley created this paste.Feb 13 2017, 4:24 PM