private function loadComments($phid)
 {
     $table = new DifferentialComment();
     $conn_r = $table->establishConnection('r');
     $rows = queryfx_all($conn_r, 'SELECT comments.* FROM %T comments ' . 'JOIN (' . ' SELECT revisionID FROM %T WHERE objectPHID = %s ' . ' UNION ALL ' . ' SELECT id from differential_revision WHERE authorPHID = %s) rel ' . 'ON (comments.revisionID = rel.revisionID)' . 'WHERE comments.action = %s' . 'AND comments.authorPHID = %s', $table->getTableName(), DifferentialRevision::RELATIONSHIP_TABLE, $phid, $phid, $this->filter, $phid);
     return $table->loadAllFromArray($rows);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $action = $request->getStr('action');
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($action);
     $comment->setAuthorPHID($author_phid);
     $handles = array($author_phid);
     $reviewers = $request->getStr('reviewers');
     if (($action == DifferentialAction::ACTION_ADDREVIEWERS || $action == DifferentialAction::ACTION_REQUEST) && $reviewers) {
         $reviewers = explode(',', $reviewers);
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers));
         $handles = array_merge($handles, $reviewers);
     }
     $ccs = $request->getStr('ccs');
     if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) {
         $ccs = explode(',', $ccs);
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs));
         $handles = array_merge($handles, $ccs);
     }
     $handles = id(new PhabricatorObjectHandleData($handles))->loadHandles();
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $draft = new PhabricatorDraft();
     $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $handles = id(new PhabricatorObjectHandleData(array($author_phid)))->loadHandles();
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($request->getStr('action'));
     $comment->setAuthorPHID($author_phid);
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $draft = new PhabricatorDraft();
     $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $action = $request->getStr('action');
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($action);
     $comment->setAuthorPHID($author_phid);
     $handles = array($author_phid);
     $reviewers = $request->getStrList('reviewers');
     if (DifferentialAction::allowReviewers($action) && $reviewers) {
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers));
         $handles = array_merge($handles, $reviewers);
     }
     $ccs = $request->getStrList('ccs');
     if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) {
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs));
         $handles = array_merge($handles, $ccs);
     }
     $handles = $this->loadViewerHandles($handles);
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $metadata = array('reviewers' => $reviewers, 'ccs' => $ccs);
     if ($action != DifferentialAction::ACTION_COMMENT) {
         $metadata['action'] = $action;
     }
     id(new PhabricatorDraft())->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->setMetadata($metadata)->replaceOrDelete();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
 private function getImplicitComments(DifferentialRevision $revision, DifferentialDiff $diff)
 {
     $author_phid = nonempty($diff->getAuthorPHID(), $revision->getAuthorPHID());
     $template = new DifferentialComment();
     $template->setAuthorPHID($author_phid);
     $template->setRevisionID($revision->getID());
     $template->setDateCreated($revision->getDateCreated());
     $comments = array();
     if (strlen($revision->getSummary())) {
         $summary_comment = clone $template;
         $summary_comment->setContent($revision->getSummary());
         $summary_comment->setAction(DifferentialAction::ACTION_SUMMARIZE);
         $comments[] = $summary_comment;
     }
     if (strlen($revision->getTestPlan())) {
         $testplan_comment = clone $template;
         $testplan_comment->setContent($revision->getTestPlan());
         $testplan_comment->setAction(DifferentialAction::ACTION_TESTPLAN);
         $comments[] = $testplan_comment;
     }
     return $comments;
 }
Beispiel #6
0
    }
}
if ($purge_changesets) {
    $table = new DifferentialChangeset();
    if ($changesets) {
        echo "Purging changeset cache for changesets " . implode($changesets, ",") . "\n";
        queryfx($table->establishConnection('w'), 'DELETE FROM %T WHERE id IN (%Ld)', DifferentialChangeset::TABLE_CACHE, $changesets);
    } else {
        echo "Purging changeset cache...\n";
        queryfx($table->establishConnection('w'), 'TRUNCATE TABLE %T', DifferentialChangeset::TABLE_CACHE);
    }
    echo "Done.\n";
}
if ($purge_differential) {
    echo "Purging Differential comment cache...\n";
    $table = new DifferentialComment();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Purging Differential inline comment cache...\n";
    $table = new DifferentialInlineComment();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Done.\n";
}
if ($purge_maniphest) {
    echo "Purging Maniphest comment cache...\n";
    $table = new ManiphestTransaction();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Done.\n";
}
echo "Ok, caches purged.\n";
function usage($message)
{
 private function findTargetDiff(array $diffs, DifferentialComment $comment)
 {
     switch ($this->filter) {
         case DifferentialAction::ACTION_CLOSE:
         case DifferentialAction::ACTION_UPDATE:
         case DifferentialAction::ACTION_COMMENT:
             return null;
         case DifferentialAction::ACTION_ACCEPT:
         case DifferentialAction::ACTION_REJECT:
             $result = head($diffs);
             foreach ($diffs as $diff) {
                 if ($diff->getDateCreated() >= $comment->getDateCreated()) {
                     break;
                 }
                 $result = $diff;
             }
             return $result;
     }
 }