public static function loadOneHandle($phid, $viewer = null)
 {
     $query = new PhabricatorObjectHandleData(array($phid));
     if ($viewer) {
         $query->setViewer($viewer);
     }
     $handles = $query->loadHandles();
     return $handles[$phid];
 }
 public final function getBlameData()
 {
     $raw_data = $this->getRawData();
     $text_list = array();
     $rev_list = array();
     $blame_dict = array();
     if (!$this->getNeedsBlame()) {
         $text_list = explode("\n", rtrim($raw_data));
     } else {
         $lines = array();
         foreach (explode("\n", rtrim($raw_data)) as $k => $line) {
             $lines[$k] = $this->tokenizeLine($line);
             list($rev_id, $author, $text) = $lines[$k];
             $text_list[$k] = $text;
             $rev_list[$k] = $rev_id;
         }
         $rev_list = $this->processRevList($rev_list);
         foreach ($lines as $k => $line) {
             list($rev_id, $author, $text) = $line;
             $rev_id = $rev_list[$k];
             if (!isset($blame_dict[$rev_id])) {
                 $blame_dict[$rev_id]['author'] = $author;
             }
         }
         $repository = $this->getRequest()->getRepository();
         $commits = id(new PhabricatorAuditCommitQuery())->withIdentifiers($repository->getID(), array_unique($rev_list))->execute();
         foreach ($commits as $commit) {
             $blame_dict[$commit->getCommitIdentifier()]['epoch'] = $commit->getEpoch();
         }
         $commits_data = array();
         if ($commits) {
             $commits_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere('commitID IN (%Ls)', mpull($commits, 'getID'));
         }
         $phids = array();
         foreach ($commits_data as $data) {
             $phids[] = $data->getCommitDetail('authorPHID');
         }
         $loader = new PhabricatorObjectHandleData(array_unique($phids));
         if ($this->viewer) {
             $loader->setViewer($this->viewer);
         }
         $handles = $loader->loadHandles();
         foreach ($commits_data as $data) {
             if ($data->getCommitDetail('authorPHID')) {
                 $commit_identifier = $commits[$data->getCommitID()]->getCommitIdentifier();
                 $blame_dict[$commit_identifier]['handle'] = $handles[$data->getCommitDetail('authorPHID')];
             }
         }
     }
     return array($text_list, $rev_list, $blame_dict);
 }
 public function execute()
 {
     $table = new PhabricatorFlag();
     $conn_r = $table->establishConnection('r');
     $where = $this->buildWhereClause($conn_r);
     $limit = $this->buildLimitClause($conn_r);
     $order = $this->buildOrderClause($conn_r);
     $data = queryfx_all($conn_r, 'SELECT * FROM %T flag %Q %Q %Q', $table->getTableName(), $where, $order, $limit);
     $flags = $table->loadAllFromArray($data);
     if ($this->needHandles || $this->needObjects) {
         $phids = ipull($data, 'objectPHID');
         $query = new PhabricatorObjectHandleData($phids);
         if ($this->viewer) {
             $query->setViewer($this->viewer);
         }
         if ($this->needHandles) {
             $handles = $query->loadHandles();
             foreach ($flags as $flag) {
                 $handle = idx($handles, $flag->getObjectPHID());
                 if ($handle) {
                     $flag->attachHandle($handle);
                 }
             }
         }
         if ($this->needObjects) {
             $objects = $query->loadObjects();
             foreach ($flags as $flag) {
                 $object = idx($objects, $flag->getObjectPHID());
                 if ($object) {
                     $flag->attachObject($object);
                 }
             }
         }
     }
     return $flags;
 }