Don't store empty drafts

Summary: We have lots of empty drafts in DB.

Test Plan: Wrote revision comment, deleted it, checked db.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3591
This commit is contained in:
vrana
2012-10-01 15:50:47 -07:00
parent 6b9b1d4f95
commit 3d6a3e28fa
5 changed files with 35 additions and 30 deletions

View File

@@ -39,18 +39,11 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
return new Aphront404Response();
}
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$task->getPHID());
if (!$draft) {
$draft = new PhabricatorDraft();
$draft->setAuthorPHID($user->getPHID());
$draft->setDraftKey($task->getPHID());
}
$draft->setDraft($comments);
$draft->save();
id(new PhabricatorDraft())
->setAuthorPHID($user->getPHID())
->setDraftKey($task->getPHID())
->setDraft($comments)
->replaceOrDelete();
$action = $request->getStr('action');